我正在使用webpack配置react,以下是我的webpack配置文件:
const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
module.exports = {
entry: path.join(__dirname, "src", "index.js"),
devtool: 'sourcemaps',
cache: true,
mode: 'development',
output: {
path:path.resolve(__dirname, "dist"),
filename: './dist/bundle.js'
},
module: {
rules: [
{
test: /\.?js$/,
exclude: /node_modules/,
use: {
loader: "babel-loader",
options: {
presets: ['@babel/preset-env', '@babel/preset-react']
}
}
},
]
},
plugins: [
new HtmlWebpackPlugin({
template: path.join(__dirname, "public/templates/", "budget_account2.html"),
}),
],
}
当我运行npm run-script watch
时,它会抛出错误:
配置对象无效。Webpack 使用不符合 API schema 的配置对象进行初始化。
- configuration.devtool 应与模式“^(inline-|hidden-|eval-)?(nosources-)?(cheap-(module-)?)?source-map$”匹配。 自 webpack 5 以来有 BREAKING CHANGE: The devtool option is more strict。
请严格遵循模式中关键字的顺序。
感谢所有人