我正在使用webpack@2.2.0-rc.3
并且extract-text-webpack-plugin@2.0.0-beta.4
我有以下 webpack 配置:
var path = require('path');
var ExtractTextPlugin = require("extract-text-webpack-plugin");
module.exports = {
entry: {
app: './source/app.js',
vendor: './source/vendor.js'
},
output: {
path: path.resolve(__dirname, './.tmp/dist'),
filename: '[name].[chunkhash].js'
},
module: {
rules: [{
test: /\.css/,
use:[ ExtractTextPlugin.extract({
loader: ["css-loader"],
})],
}],
},
plugins: [
new ExtractTextPlugin({
filename: "[name].[chunkhash].css",
allChunks: true,
})
]
};
在vendor.js
文件中,我有以下代码:
require("./asdf.css")
在asdf.css
我的代码中
body {
background: yellow;
}
这是一个非常简单的设置,但是在运行 webpack 时出现此错误:
ERROR in ./source/asdf.css
Module build failed: ModuleParseError: Module parse failed: /home/vagrant/dorellang.github.io/source/asdf.css Unexpected token (1:5)
You may need an appropriate loader to handle this file type.
| body {
| background: yellow;
| }
at /home/vagrant/dorellang.github.io/node_modules/webpack/lib/NormalModule.js:210:34
at /home/vagrant/dorellang.github.io/node_modules/webpack/lib/NormalModule.js:164:10
at /home/vagrant/dorellang.github.io/node_modules/loader-runner/lib/LoaderRunner.js:365:3
at iterateNormalLoaders (/home/vagrant/dorellang.github.io/node_modules/loader-runner/lib/LoaderRunner.js:206:10)
at Array.<anonymous> (/home/vagrant/dorellang.github.io/node_modules/loader-runner/lib/LoaderRunner.js:197:4)
at Storage.finished (/home/vagrant/dorellang.github.io/node_modules/enhanced-resolve/lib/CachedInputFileSystem.js:38:15)
at /home/vagrant/dorellang.github.io/node_modules/enhanced-resolve/lib/CachedInputFileSystem.js:69:9
at /home/vagrant/dorellang.github.io/node_modules/graceful-fs/graceful-fs.js:78:16
at FSReqWrap.readFileAfterClose [as oncomplete] (fs.js:445:3)
@ ./source/vendor.js 2:0-21
我究竟做错了什么?