Angularjs 提取文本网页包插件获取.css文件输出的困难
我用的是AngularClass的角形种子。我有一个application.scss文件,我正试图通过webpack和extract text webpack插件将其导出到css文件中。我正在关注此处找到的网页包样式表页面: 但在运行webpack之后,我似乎无法使我的.css文件显示在我的/dist文件夹中 有人有什么想法吗 我已经在下面包含了我的网页配置文件Angularjs 提取文本网页包插件获取.css文件输出的困难,angularjs,webpack,Angularjs,Webpack,我用的是AngularClass的角形种子。我有一个application.scss文件,我正试图通过webpack和extract text webpack插件将其导出到css文件中。我正在关注此处找到的网页包样式表页面: 但在运行webpack之后,我似乎无法使我的.css文件显示在我的/dist文件夹中 有人有什么想法吗 我已经在下面包含了我的网页配置文件 /** *@作者:@AngularClass */ const webpack=require('webpack'); const
/**
*@作者:@AngularClass
*/
const webpack=require('webpack');
const helpers=require('./helpers');
/*
*网页包插件
*/
//复制网页包插件有问题
var CopyWebpackPlugin=(CopyWebpackPlugin=require('copy-webpack-plugin'),CopyWebpackPlugin.default | | CopyWebpackPlugin);
const HtmlWebpackPlugin=require('html-webpack-plugin');
const ForkCheckerPlugin=require('awesome-typescript-loader')。ForkCheckerPlugin;
var ExtractTextPlugin=require('extract-text-webpack-plugin');
/*
*网页包常量
*/
常量元数据={
标题:'Angular2网页包启动程序由@gdi2290从@AngularClass',
baseUrl:“/”
};
/*
*网页包配置
*
*见:http://webpack.github.io/docs/configuration.html#cli
*/
module.exports={
/*
*index.html的静态元数据
*
*请参见:(自定义属性)
*/
元数据:元数据,
/*
*缓存生成的模块和块,以提高多个增量构建的性能。
*这在监视模式下默认启用。
*您可以传递false来禁用它。
*
*见:http://webpack.github.io/docs/configuration.html#cache
*cache:false,
*
*包的入口点
*我们的Angular.js应用程序
*
*见:http://webpack.github.io/docs/configuration.html#entry
*/
条目:{
“polyfills”:“./src/polyfills.ts”,
“供应商”:“./src/vendor.ts”,
“main”:“./src/main.browser.ts”
},
输出:{
路径:helpers.root('dist'),
文件名:'[name].bundle.js',
sourceMapFilename:“[name].map”
},
/*
*影响模块解析的选项。
*
*见:http://webpack.github.io/docs/configuration.html#resolve
*/
决心:{
/*
*应用于解析模块的扩展数组。
*
*见:http://webpack.github.io/docs/configuration.html#resolve-扩展
*/
扩展名:['','.ts','.js'],
//确保root是src
root:helpers.root('src'),
//删除其他默认值
模块目录:['node_modules'],
别名:{
“angular2/core”:helpers.root('node_modules/@angular/core/index.js'),
“angular2/testing”:helpers.root('node_modules/@angular/core/testing.js'),
“@angular/testing”:helpers.root('node_modules/@angular/core/testing.js'),
“angular2/platform/browser”:helpers.root('node_modules/@angular/platform browser/index.js'),
“angular2/router”:helpers.root('node_modules/@angular/router已弃用/index.js'),
“angular2/http”:helpers.root('node_modules/@angular/http/index.js'),
“angular2/http/testing”:helpers.root('node_modules/@angular/http/testing.js')
},
},
/*
*影响正常模块的选项。
*
*见:http://webpack.github.io/docs/configuration.html#module
*/
模块:{
/*
*一系列应用的前置和后置加载程序。
*
*见:http://webpack.github.io/docs/configuration.html#module-预加载模块后加载程序
*/
预紧器:[
/*
*Tslint加载程序支持*.ts文件
*
*见:https://github.com/wbuchwalter/tslint-loader
*/
//{test:/\.ts$/,loader:'tslint loader',exclude:[helpers.root('node\u modules')]},
/*
*源地图加载器支持*.js文件
*为添加为sourceMappingURL注释的源文件提取SourceMaps。
*
*见:https://github.com/webpack/source-map-loader
*/
{
测试:/\.js$/,,
加载器:“源地图加载器”,
排除:[
//这些包的源地图有问题
根('node_modules/rxjs'),
helpers.root('node_modules/@angular2 material'),
根('node_modules/@angular'),
]
}
],
/*
*一组自动应用的加载程序。
*
*重要提示:此处的加载程序是相对于应用它们的资源进行解析的。
*这意味着它们不会相对于配置文件进行解析。
*
*见:http://webpack.github.io/docs/configuration.html#module-装载机
*/
装载机:[
/*
*Typescript加载程序通过.async.ts支持.ts和Angular 2异步路由
*
*见:https://github.com/s-panferov/awesome-typescript-loader
*/
{
测试:/\.ts$/,,
加载器:“很棒的类型脚本加载器”,
排除:[/\(规范e2e)\.ts$/]
},
/*
*Json加载程序支持*.Json文件。
*
*见:https://github.com/webpack/json-loader
*/
{
测试:/\.json$/,,
加载程序:“json加载程序”
},
{
测试:/\(png | jpg)$/,
加载器:“url加载器?限制=8192”
},
{
测试:/\.scss$/,,
加载器:ExtractTextPlugin.extract('style-loader','css loader!sass loader'))
},
{
测试:/\.css$/,,
加载器:ExtractTextPlugin.extract('style-loader','css-loader')
},
{test:/\.woff(2)?(\?v=[0-9]\[0-9]\[0-9])?$/,加载程序:“url加载程序?限制=10000&mimetype=application/font-woff”,
{test://\(ttf | eot | svg)(\?v=[0-9]\[0-9]\[0-9])?$/,加载程序:“文件加载程序”},
/*对*.html的原始加载程序支持
*以字符串形式返回文件内容
*
*见:https://github.com/webpack/raw-loader
*/
{
测试:/\.html$/,,
加载器:“原始加载器”,
排除:[helpers.root('src/index.html')]
}
]
},
/*
*向编译器添加其他插件。
*
*见:http://webpack.github.io/docs/configuration.html#plugins
*/
/**
* @author: @AngularClass
*/
const webpack = require('webpack');
const helpers = require('./helpers');
/*
* Webpack Plugins
*/
// problem with copy-webpack-plugin
var CopyWebpackPlugin = (CopyWebpackPlugin = require('copy-webpack-plugin'), CopyWebpackPlugin.default || CopyWebpackPlugin);
const HtmlWebpackPlugin = require('html-webpack-plugin');
const ForkCheckerPlugin = require('awesome-typescript-loader').ForkCheckerPlugin;
/*
* Webpack Constants
*/
const METADATA = {
title: 'Angular2 Webpack Starter by @gdi2290 from @AngularClass',
baseUrl: '/'
};
/*
* Webpack configuration
*
* See: http://webpack.github.io/docs/configuration.html#cli
*/
module.exports = {
/*
* Static metadata for index.html
*
* See: (custom attribute)
*/
metadata: METADATA,
/*
* Cache generated modules and chunks to improve performance for multiple incremental builds.
* This is enabled by default in watch mode.
* You can pass false to disable it.
*
* See: http://webpack.github.io/docs/configuration.html#cache
* cache: false,
*
* The entry point for the bundle
* Our Angular.js app
*
* See: http://webpack.github.io/docs/configuration.html#entry
*/
entry: {
'polyfills': './src/polyfills.ts',
'vendor': './src/vendor.ts',
'main': './src/main.browser.ts'
},
output:{
path: helpers.root('dist'),
filename: '[name].bundle.js',
sourceMapFilename: '[name].map'
},
/*
* Options affecting the resolving of modules.
*
* See: http://webpack.github.io/docs/configuration.html#resolve
*/
resolve: {
/*
* An array of extensions that should be used to resolve modules.
*
* See: http://webpack.github.io/docs/configuration.html#resolve-extensions
*/
extensions: ['', '.ts', '.js'],
// Make sure root is src
root: helpers.root('src'),
// remove other default values
modulesDirectories: ['node_modules'],
alias: {
'angular2/core': helpers.root('node_modules/@angular/core/index.js'),
'angular2/testing': helpers.root('node_modules/@angular/core/testing.js'),
'@angular/testing': helpers.root('node_modules/@angular/core/testing.js'),
'angular2/platform/browser': helpers.root('node_modules/@angular/platform-browser/index.js'),
'angular2/router': helpers.root('node_modules/@angular/router-deprecated/index.js'),
'angular2/http': helpers.root('node_modules/@angular/http/index.js'),
'angular2/http/testing': helpers.root('node_modules/@angular/http/testing.js')
},
},
/*
* Options affecting the normal modules.
*
* See: http://webpack.github.io/docs/configuration.html#module
*/
module: {
/*
* An array of applied pre and post loaders.
*
* See: http://webpack.github.io/docs/configuration.html#module-preloaders-module-postloaders
*/
preLoaders: [
/*
* Tslint loader support for *.ts files
*
* See: https://github.com/wbuchwalter/tslint-loader
*/
// { test: /\.ts$/, loader: 'tslint-loader', exclude: [ helpers.root('node_modules') ] },
/*
* Source map loader support for *.js files
* Extracts SourceMaps for source files that as added as sourceMappingURL comment.
*
* See: https://github.com/webpack/source-map-loader
*/
{
test: /\.js$/,
loader: 'source-map-loader',
exclude: [
// these packages have problems with their sourcemaps
helpers.root('node_modules/rxjs'),
helpers.root('node_modules/@angular2-material'),
helpers.root('node_modules/@angular'),
]
}
],
/*
* An array of automatically applied loaders.
*
* IMPORTANT: The loaders here are resolved relative to the resource which they are applied to.
* This means they are not resolved relative to the configuration file.
*
* See: http://webpack.github.io/docs/configuration.html#module-loaders
*/
loaders: [
/*
* Typescript loader support for .ts and Angular 2 async routes via .async.ts
*
* See: https://github.com/s-panferov/awesome-typescript-loader
*/
{
test: /\.ts$/,
loader: 'awesome-typescript-loader',
exclude: [/\.(spec|e2e)\.ts$/]
},
/*
* Json loader support for *.json files.
*
* See: https://github.com/webpack/json-loader
*/
{
test: /\.json$/,
loader: 'json-loader'
},
{
test: /\.(png|jpg)$/,
loader: 'url-loader?limit=8192'
},
{
test: /\.scss$/,
loader: ExtractPlugin.extract('style', 'css!sass'),
},
{ test: /\.woff(2)?(\?v=[0-9]\.[0-9]\.[0-9])?$/, loader: "url-loader?limit=10000&mimetype=application/font-woff" },
{ test: /\.(ttf|eot|svg)(\?v=[0-9]\.[0-9]\.[0-9])?$/, loader: "file-loader" },
/* Raw loader support for *.html
* Returns file content as string
*
* See: https://github.com/webpack/raw-loader
*/
{
test: /\.html$/,
loader: 'raw-loader',
exclude: [helpers.root('src/index.html')]
}
]
},
/*
* Add additional plugins to the compiler.
*
* See: http://webpack.github.io/docs/configuration.html#plugins
*/
plugins: [
/*Try using this*/
new ExtractPlugin('main.css'),
/*
* Plugin: ForkCheckerPlugin
* Description: Do type checking in a separate process, so webpack don't need to wait.
*
* See: https://github.com/s-panferov/awesome-typescript-loader#forkchecker-boolean-defaultfalse
*/
new ForkCheckerPlugin(),
/*
* Plugin: OccurenceOrderPlugin
* Description: Varies the distribution of the ids to get the smallest id length
* for often used ids.
*
* See: https://webpack.github.io/docs/list-of-plugins.html#occurrenceorderplugin
* See: https://github.com/webpack/docs/wiki/optimization#minimize
*/
new webpack.optimize.OccurenceOrderPlugin(true),
/*
* Plugin: CommonsChunkPlugin
* Description: Shares common code between the pages.
* It identifies common modules and put them into a commons chunk.
*
* See: https://webpack.github.io/docs/list-of-plugins.html#commonschunkplugin
* See: https://github.com/webpack/docs/wiki/optimization#multi-page-app
*/
new webpack.optimize.CommonsChunkPlugin({
name: ['polyfills', 'vendor'].reverse()
}),
/*
* Plugin: CopyWebpackPlugin
* Description: Copy files and directories in webpack.
*
* Copies project static assets.
*
* See: https://www.npmjs.com/package/copy-webpack-plugin
new CopyWebpackPlugin([{
from: 'src/assets',
to: 'assets'
}]),
*/
/*
* Plugin: HtmlWebpackPlugin
* Description: Simplifies creation of HTML files to serve your webpack bundles.
* This is especially useful for webpack bundles that include a hash in the filename
* which changes every compilation.
*
* See: https://github.com/ampedandwired/html-webpack-plugin
*/
new HtmlWebpackPlugin({
template: 'src/index.html',
chunksSortMode: 'dependency'
})
],
/*
* Include polyfills or mocks for various node stuff
* Description: Node configuration
*
* See: https://webpack.github.io/docs/configuration.html#node
*/
node: {
global: 'window',
crypto: 'empty',
module: false,
clearImmediate: false,
setImmediate: false
}
};
path.join(__dirname, 'src', 'assets', 'sass', 'application.scss')