我遇到了使用ExtractTextPlugin和css-loader打包css文件的问题。这是我配置的一部分:
plugins: [
...
new ExtractTextPlugin("[name].css")
],
module: {
loaders: [
...
{
test: /\.css$/,
loader: ExtractTextPlugin.extract("style", "css")
},
{
test: /\.less$/,
loader: ExtractTextPlugin.extract("style", "css!less")
}
...
],
noParse: []
}
当我尝试编译我的资源时,它会出错:
ERROR in ./~/angular-bootstrap-datetimepicker/src/css/datetimepicker.css
Module build failed: Error: Cannot find module '../../../css-loader/lib/css-base.js'
//OTHER ERRORS WITH ALL CSS FILES
ERROR in ./~/datatables/media/css/jquery.dataTables.css
Module build failed: Error: Cannot find module '../../../css-loader/lib/css-base.js'
...
[363] ./~/jquery-ui/themes/base/all.css 865 bytes {1} [built] [failed]
[364] ./~/bootstrap/dist/css/bootstrap.css 883 bytes {1} [built] [failed]
[365] ./~/datatables/media/css/jquery.dataTables.css 907 bytes {1} [built] [failed]
[366] ./~/angular-datatables/dist/css/angular-datatables.css 910 bytes {1} [built] [failed]
[367] ./~/angular-bootstrap-datetimepicker/src/css/datetimepicker.css 898 bytes {1} [built] [failed]
[368] ./~/highcharts/css/highcharts.css 874 bytes {1} [built] [failed]
换句话说,它无法找到css-loader模块。我的devDependencies
部分来自package.json
:
"css-loader": "^0.25.0",
"exports-loader": "^0.6.3",
"extract-text-webpack-plugin": "^1.0.1",
"less": "^2.7.1",
"less-loader": "^2.2.3",
"style-loader": "^0.13.1",
"webpack": "1.13.3",
"webpack-dev-server": "1.16.2"
另一个有趣的事情是,这个配置在Windows上完美运行,但是我试图在Ubuntu上运行它并获得这些错误。有人能帮我吗?