javascript - Webpack-CLI 错误:配置对象无效
问题描述
我在互联网上搜索了这个问题的答案,但找不到能回答我遇到的具体问题的答案。我创建了一个 webpack.config.js,当我尝试使用 webpack-cli 运行它时,我收到以下错误消息
[webpack-cli] Invalid configuration object. Webpack has been initialized using a configuration object that does not match the API schema.
- configuration.module.rules[0] has an unknown property 'query'. These properties are valid:
object { compiler?, dependency?, descriptionData?, enforce?, exclude?, generator?, include?, issuer?, issuerLayer?, layer?, loader?, mimetype?, oneOf?, options?, parser?, realResource?, resolve?, resource?, resourceFragment?, resourceQuery?, rules?, sideEffects?, test?, type?, use? }
-> A rule description with conditions and effects for modules.
这是我的 webpack.config.js 文件
// Load the needed node modules
var path = require("path");
var webpack = require('webpack');
var BundleTracker = require('webpack-bundle-tracker');
// Webpack project settings
module.exports = {
context: __dirname,
entry: {
lobby: './templates/components/lobby/index',
},
output: {
path: path.resolve('./static/bundles/'),
filename: "[name]-[hash].js"
},
plugins: [
new webpack.HotModuleReplacementPlugin(),
new webpack.NoEmitOnErrorsPlugin(), // don't reload if there is an error
new BundleTracker({path: __dirname, filename: './webpack-stats.json'})
],
module: {
rules: [
{
test: /\.jsx$/,
exclude: /(node_modules)/,
loader: 'babel-loader', // 'babel-loader' is also a legal name to reference
query: {
presets: ['es2015', 'react']
}
},
]
},
resolve: {
modules: ['node_modules'],
extensions: ['.jsx', '.js']
}
}
我对 Webpack 不是很熟练,但是我遵循了一些关于它的教程,我认为它看起来应该如何设置 webpack 文件,所以我不知道为什么会出现这个错误。
解决方案
推荐阅读
- javascript - 如何在 javascript 中从 base64 数据创建 xls 文件
- python - TensorFlow Python - 有没有办法将 tensorflow_datasets 数据集插入 ImageGenerator?
- javascript - 导航栏在向上滚动 1 像素时变得粘滞 - 我希望它仅在滚动超过 10 像素时出现
- firebase - 在 firestore 集合中,如何防止 auth 用户在集合中添加太多文档?
- android - IBM 的 Speech to Text 的 Retrofit2 身份验证错误
- xamarin - 如何下载/导出 .net core localhost 生成的证书
- reactjs - 如何从 API 响应中交叉引用 ID
- node.js - 使用 gruntjs 自动构建 html
- tensorflow - Tensorflow:将模型转换为 TFLite 格式
- ios - 致命错误:在隐式展开可选值时意外发现 nil。火箭发射