前言,关于extract-text-webpack-plugin插件的使用可以参考http://www.jianshu.com/p/439764e3eff2这篇文章。
1.提示Chunk.entry was removed. Use hasRuntime()
这个主要是webpack版本和extract-text-webpack-plugin插件对应的版本不一致的原因。
现在我们使用的最新版是webpack3.0版本了,所以对应安装也应该有选择。
# for webpack 3
npm install --save-dev extract-text-webpack-plugin
# for webpack 2
npm install --save-dev extract-text-webpack-plugin@2.1.2
# for webpack 1
npm install --save-dev extract-text-webpack-plugin@1.0.1
如果安装之前网上教程,因为时效性问题,可能会出现版本对应问题,还有extract-text-webpack-plugin插件具体使用方法可参考官网https://www.npmjs.com/package/extract-text-webpack-plugin
2.出现如下报错:
ERROR in ./src/page/index/index.css
Module build failed: ModuleParseError: Module parse failed: C:\Git\repository\mike-mmail-fel\src\page\index\index.css Unexpected token (8:4)
You may need an appropriate loader to handle this file type.
这个也是因为版本的问题,因为现在是3.0版本了,现在教程大多是2.0或1.0版本的文章了,对于loader设置不一样,3.0版本应该设置成如下:
module:{
loaders:[
{
test: /\.css$/,
use: ExtractTextPlugin.extract({
fallback: "style-loader",
use: "css-loader"
})
}
]
},
plugins: [
new ExtractTextPlugin({
filename: 'css/[name].css'
}),
]