在webpack4下用babel present 问题

来源:3-3 由浅入深 webpack - 编译 ES6

Jokky

2018-08-09

Invalid configuration object. Webpack has been initialised using a configuration object that does not match the API schema.

 - configuration.module has an unknown property 'exclude'. These properties are valid:

   object { exprContextCritical?, exprContextRecursive?, exprContextRegExp?, exprContextRequest?, noParse?, rules?, defaultRules?, unknownContextCritical?, unknownContextRecursive?, unknownContextRegExp?, unknownContextRequest?, unsafeCache?, wrappedContextCritical?, wrappedContextRecursive?, wrappedContextRegExp?, strictExportPresence?, strictThisContextOnImports? }

   -> Options affecting the normal modules (`NormalModuleFactory`).

webpack.config.js

module.exports = {
    entry: {
        app: './app.js'
    },
    output: {
        filename: '[name].[hash:8].js'
    },
    module: {
        rules: [
            {
                test: /\.js$/,
                exclude: '/node_modules/',
                use: {
                    loader: 'babel-loader'
                }
            }
        ]
    }

    


写回答

1回答

qbaty

2018-08-09

我怀疑你是不是括号写错了?

configuration.module has an unknown property 'exclude'. 这个意思是webpack识别到你的 配置的module 里有一个未知的属性:exclude,你可以检查一下你的配置是否写错了,exclude 应该是在单独的rule 里

0
1
Jokky
好的,谢谢
2018-08-09
共1条回复

四大维度解锁Webpack3.0前端工程化

前端开发标配,灵活掌握Webpack3.0的使用可以极大的提高前端开发的效率

1188 学习 · 403 问题

查看课程