【发布时间】:2021-04-04 06:38:48
【问题描述】:
我正在使用一个自定义的 webpack 配置文件:
var webpack = require('webpack');
var path = require('path');
module.exports = {
entry: {
app: './src/index.js'
},
output: {
filename: 'dist/bundle.js',
sourceMapFilename: 'dist/bundle.map'
},
devtool: '#source-map',
module: {
loaders: [
{
loader: 'babel-loader',
exclude: /(node_modules)/,
query: {
presets: [ 'react', 'es2015' ]
}
}
]
}
};
当我在终端运行wepback 时会引发错误:
Invalid configuration object. Webpack has been initialised using a configuration object that does not match the API schema.
- configuration.module has an unknown property 'loaders'. These properties are valid:
object { defaultRules?, exprContextCritical?, exprContextRecursive?, exprContextRegExp?, exprContextRequest?, noParse?, rules?, strictExportPresence?, strictThisContextOnImports?, unknownContextCritical?, unknownContextRecursive?, unknownContextRegExp?, unknownContextRequest?, unsafeCache?, wrappedContextCritical?, wrappedContextRecursive?, wrappedContextRegExp? }
-> Options affecting the normal modules (`NormalModuleFactory`).
如何正确使用 webpack 的自定义配置文件并修复此错误?
【问题讨论】:
-
您可以观看正在运行的 webpack 配置here。
标签: javascript reactjs webpack babeljs