0

I recently installed webpack and webpack-dev-server and getting this error on running it from terminal.

error: [webpack-cli] Invalid options object. Dev Server has been initialized using an options object that does not match the API schema. - options has an unknown property 'contentBase'. These properties are valid: object { allowedHosts?, bonjour?, client?, compress?, devMiddleware?, headers?, historyApiFallback?, host?, hot?, http2?, https?, ipc?, liveReload?, magicHtml?, onAfterSetupMiddleware?, onBeforeSetupMiddleware?, onListening?, open?, port?, proxy?, server?, setupExitSignals?, static?, watchFiles?, webSocketServer? }

1 Answers1

1

Now webpack changed contentBase to static

To install webpack-dev-server

yarn add webpack-dev-server

or

npm install webpack-dev-server

then in webpack.config.js add this code

devServer: {
    static: {
        directory: path.join(__dirname, './public'),
    },
    // hot: true,
}
Ahmed Radi
  • 677
  • 1
  • 5
  • 20