我一直在使用这个 webpack 配置来加载 babel 和 css 加载器,但出现错误。如果我只使用 babel 加载器,但 css 加载器不起作用,我的 webpack 配置工作得很好。
var path = require('path');
var config = {
entry: './main.js',
output: {
path : path.join(__dirname, './'),
filename: 'index.js',
},
devServer: {
inline: true,
port: 8080
},
module: {
loaders: [
{
test: /\.jsx?$/,
exclude: /node_modules/,
loader: 'babel-loader',
query: {
presets: ['es2015', 'react']
}
},
{
test: /\.jsx?$/,
exclude: /node_modules/,
loader: 'style-loader!css-loader',
}
]
}
}
module.exports = config;
我在运行 webpack 时遇到的错误是
ERROR in ./~/css-loader!./main.js