webpack-dev-middleware:选项有一个未知的属性“logLevel”

问题描述

我目前正在升级 Webpack + 相关模块,但出现以下错误。这有点令人困惑,因为我们没有指定提到的配置参数。任何帮助将不胜感激。

[webpack-cli] Invalid options object. Dev Middleware has been initialized using an options object that does not match the API schema.
 - options has an unkNown property 'logLevel'. These properties are valid:
   object { mimeTypes?,writetodisk?,methods?,headers?,publicPath?,stats?,serverSideRender?,outputFileSystem?,index? }

我们的 webpack devServer 配置如下:

const config = {
    entry: path.resolve(PATHS.src,`index.tsx`),mode: devEnv ? "development" : "production",devtool: devEnv ? "eval-source-map" : "source-map",devServer: {
        hot: true,historyApiFallback: true,contentBase: PATHS.dist,port: 3000,stats: "errors-warnings",host: "0.0.0.0",compress: true,before(app) {
            app.use(compression({}));
        },},output: {
        path: PATHS.dist,publicPath: "",filename: "xxx.[name].[fullhash].js",chunkFilename: "xxx.[name].[chunkhash].js",clean: true,resolve: {
        extensions: [".ts",".tsx",".js",".jsx"],alias: {
            srcRootDir: path.resolve(__dirname,"src/"),react: "preact/compat","react-dom/test-utils": "preact/test-utils",// react-dom must be last says preact docs.
            "react-dom": "preact/compat",module: {
        rules: [
            {
                test: /\.(t|j)sx?$/,exclude: /node_modules/,use: [
                    {
                        loader: "babel-loader",],{ enforce: "pre",test: /\.js$/,loader: "source-map-loader" },{
                test: /\.(png|svg|jpg|gif)$/,type: "asset/resource",plugins: [
        new HtmlWebpackPlugin({
            templateParameters: {
                title: "xxx",template: path.resolve(PATHS.src,"static/index.html"),}),new copyPlugin({
            patterns: [
                {
                    from: path.resolve(PATHS.src,"static"),to: PATHS.dist,optimization: {
        splitChunks: {
            chunks: "all",minimize: true,minimizer: [
            new TerserPlugin({
                extractComments: false,};

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)