0

我将我的问题归结为最低限度的测试。我有一个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: []因为同样的错误而失败。

有人有想法吗?

4

1 回答 1

1

include就像test

  • include: []表示“不包含任何内容”`
  • include: ["./include"]表示“仅包含目录中的include文件”

因此,如果那些将排除./App.js.

于 2018-01-31T21:58:01.573 回答