我有js loader的webpack配置
module: {
loaders: [
{
test: /\.js?$/,
loader: 'babel-loader',
exclude: /node_modules/,
query: {
"presets": ["es2015", "stage-0", "react"],
"plugins": ['transform-runtime']
}
},
它有效,但当我尝试将加载器更改为规则时,它不起作用,我得到了这个错误:
ERROR in ./src/index.js
Module parse failed: D:\src\index.js Unexpected token (16:4)
You may need an appropriate loader to handle this file type.
|
| render(
| <Router history={browserHistory}>
| <Route path='/' component={App}>
| <IndexRoute component={Home} />
答案 0 :(得分:0)
The syntax for rules
is not the same as the syntax for loaders
.在你的情况下看起来应该是这样的:
module: {
rules: [
{
test: /\.js?$/,
loader: 'babel-loader',
exclude: /node_modules/,
options: {
presets: ["es2015", "stage-0", "react"],
plugins: ['transform-runtime']
}
}
]
}