【发布时间】:2018-07-11 01:56:27
【问题描述】:
我将我的问题归结为最低限度的测试。我有一个 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: [] 也会失败并出现同样的错误。
有人有想法吗?
【问题讨论】:
标签: webpack babeljs jsx babel-loader