我将我的问题归结为最低限度的测试。我有一个App.js
包含一些 jsx 的文件,该文件将被编译为./bundle.js
:
// App.js
module.exports = () => <div/>
我的 webpack 配置看起来很标准
module.exports = {
entry: './App.js',
output: {
filename: './bundle.js'
},
module: {
loaders: [
{
test: /\.js$/,
loader: 'babel-loader',
//include: ['./includes'], // <- Problem line
query: {
plugins: [
['transform-react-jsx']
]
}
}
]
}
}
仅当include
删除行时,这才有效并正确编译。如果我启用该行,那么我会收到错误
Module parse failed: ./App.js Unexpected token (1:23)
You may need an appropriate loader to handle this file type.
| module.exports = () => <div/>
我不知道为什么当我为加载程序指定一个包含时它会失败,甚至会include: []
因为同样的错误而失败。
有人有想法吗?