编译时出现此错误。
./src/app/app.component.css中的ERROR模块构建失败:错误: 使用“ extract-text-webpack-plugin”加载程序时不使用 相应的插件,请参阅 https://github.com/webpack/extract-text-webp确认使用插件 例 在Object.pitch(C:\ Users \ Flamelsoft \ source \ repos \ Ecommerce \ Ecommerce \ node_m odules \ extract-text-webpack-plugin \ dist \ loader.js:57:11)
我的代码webpack.config.js是:
var webpack = require('webpack');
var path = require('path');
var HtmlWebpackPlugin = require('html-webpack-plugin');
var ExtractTextPlugin = require("extract-text-webpack-plugin");
module.exports = {
entry: path.resolve(__dirname, 'src/main.ts'),
devServer: {
proxy: {
'/api': {
target: 'http://localhost:63995',
secure: false
}
}
},
output: {
path: path.resolve(__dirname, 'wwwroot'),
filename: 'app.[hash].js'
},
module: {
rules: [
{ test: /\.component.ts$/, loaders: 'angular2-template-loader' },
{ test: /\.ts$/, loaders: 'awesome-typescript-loader' },
{ test: /\.html$/, loaders: 'html-loader' },
{ test: /\.css$/, loaders: 'css-loader' },
{ test: /\.css$/, loaders: ExtractTextPlugin.extract({ fallback: "style-loader", use: "css-loader" }) }
]
},
resolve: {
extensions: ['*', '.js', '.ts', '.html', '.css']
},
plugins: [
new HtmlWebpackPlugin({
template: './src/index.html'
})
]
};
我正在使用:
"devDependencies": {
"@types/node": "~8.9.4",
"angular2-template-loader": "~0.6.2",
"awesome-typescript-loader": "~3.5.0",
"copy-webpack-plugin": "~4.4.2",
"css-loader": "~0.28.10",
"extract-text-webpack-plugin": "^3.0.2",
"file-loader": "~1.1.9",
"html-elements-webpack-plugin": "~1.0.1",
"html-loader": "~0.5.5",
"html-webpack-plugin": "~2.30.1",
"raw-loader": "~0.5.1",
"resolve-url-loader": "~2.2.1",
"style-loader": "~0.20.2",
"to-string-loader": "~1.1.5",
"ts-loader": "~3.5.0",
"typescript": "~2.7.2",
"url-loader": "~0.6.2",
"webpack": "~3.11.0",
"webpack-dev-server": "~2.11.1"
}
任何解决方案?,我将非常感谢
答案 0 :(得分:0)
解决方案与错误消息中所说的相同:
plugins: [
new HtmlWebpackPlugin({
template: './src/index.html'
}),
new ExtractTextPlugin() // <-------------
]