I am using webpack - v5.90.3, webpack-cli - v5.1.4, webpack-dev-server - v5.0.2

In my webpack.config.dev.js:

const path = require('path');
const webpack = require('webpack');

module.exports = {
  mode: 'development',
  devtool: 'cheap-module-source-map',

  devServer: {
    static: path.join(__dirname, 'public/'),
    devMiddleware: {
      publicPath: '/dist/'
    },
    port: 3000,
    hot: "only"

  },

  entry: [
    require.resolve('react-dev-utils/webpackHotDevClient'),
    paths.appIndexJs,
  ],
  output: {

    path: paths.appBuild,

    pathinfo: true,
    filename: 'SHSADCAA/static/js/bundle.js',
    chunkFilename: 'SHSADCAA/static/js/[name].chunk.js',
    publicPath: publicPath,
    devtoolModuleFilenameTemplate: info =>
      path.resolve(info.absoluteResourcePath).replace(/\\/g, '/'),
  },
  optimization: {
    splitChunks: {
      chunks: 'all',
      name: false,
    },
    runtimeChunk: true,
  },
  resolve: {
      process.env.NODE_PATH.split(path.delimiter).filter(Boolean)
    ),
      'react-native': 'react-native-web',
    },
    plugins: [
      PnpWebpackPlugin,
      new ModuleScopePlugin(paths.appSrc, [paths.appPackageJson]),
    ],
  },
  resolveLoader: {
    plugins: [
      PnpWebpackPlugin.moduleLoader(module),
    ],
  },

I got this error:

Invalid options object. Dev Server has been initialized using an options object that does not match the API schema.

  • options has an unknown property '_assetEmittingPreviousFiles'. These properties are valid: object { allowedHosts?, bonjour?, client?, compress?, devMiddleware?, headers?, historyApiFallback?, host?, hot?, ipc?, liveReload?, onListening?, open?, port?, proxy?, server?, setupExitSignals?, setupMiddlewares?, static?, watchFiles?, webSocketServer? }

I'm trying to migrate from v3 to v5, but I'm still stuck on this one.

1

There are 1 best solutions below

0
LuckyLuke On

Had sample problem, there is a thread on github repository. https://github.com/webpack/webpack-cli/issues/2894

In my case I am having script that start app under webpack dev server. And it seems that configuration object must be passed first, and only then compiler must be passed.

This didn't worked:

const webpackDevServer = new WebpackDevServer(compiler, { port: 5000, open: true, liveReload: true });

This worked:

const webpackDevServer = new WebpackDevServer({ port: 5000, open: true, liveReload: true }, compiler);

Your case might be different, but I was having same error with (1) approach.