webpack 5 不接受 devtool 的任何设置

mke*_*e21 3 javascript webpack

使用 webpack 5 构建时,出现错误:

[webpack-cli] Invalid configuration object. Webpack has been initialized using a configuration object that does not match the API schema.
 - configuration.devtool should match pattern "^(inline-|hidden-|eval-)?(nosources-)?(cheap-(module-)?)?source-map$".
   BREAKING CHANGE since webpack 5: The devtool option is more strict.
   Please strictly follow the order of the keywords in the pattern.
Run Code Online (Sandbox Code Playgroud)

然而,在我的 webpack.config.js 中,我有以下设置:

    devtool: 'eval-cheap-source-map',
Run Code Online (Sandbox Code Playgroud)

我也尝试过eval作为值,但也不起作用,尽管该网站(https://webpack.js.org/configuration/devtool/)似乎表明它应该起作用。我不明白,这里出了什么问题?

编辑:我的 webpack.config.js

const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');

module.exports = {
    entry: './src/app.js',
    plugins: [
        new HtmlWebpackPlugin({
            title: 'MyApp',
        }),
    ],
    output: {
        filename: 'main.js',
        path: path.resolve(__dirname, 'dist'),
        libraryTarget: 'var',
        library: 'MyApp'
    },
    resolve:{
        alias:{
            EVENTS: path.resolve(__dirname, "src/events"),
            MODELS: path.resolve(__dirname, "src/models"),
            GUI: path.resolve(__dirname, "src/gui"),
            HELPER: path.resolve(__dirname, "src/helper")
        }
    },
    devtool: 'eval-cheap-source-map',
    devServer: {
        watchContentBase: true,
        contentBase: path.resolve(__dirname, 'dist'),
        port: 9000
    },
    module: {
        rules: [
            {
                test:/\.css$/,
                use:['style-loader', 'css-loader']
            }
        ]
    },
}
Run Code Online (Sandbox Code Playgroud)

我的构建脚本是webpack src/app.js -d --watch

Mar*_*min 9

-d从构建脚本中删除该参数。-d代表 devtool,但命令中后面没有参数值。