Search code examples
webpackwebpack-dev-serverwebpack-cli

Webpack Dev Server Config - contentBase not working in latest version


When I upgrade webpack to 4.0.0-beta.3 and run npx webpack serve I get this error:

[webpack-cli] Invalid configuration object. Object has been initialized using a configuration object that does not match the API schema.
 - configuration has an unknown property 'contentBase'. These properties are valid:
   object { bonjour?, client?, compress?, devMiddleware?, firewall?, headers?, historyApiFallback?, host?, hot?, http2?, https?, liveReload?, onAfterSetupMiddleware?, onBeforeSetupMiddleware?, onListening?, open?, port?, proxy?, public?, setupExitSignals?, static?, transportMode?, watchFiles? }

This is my webpack.config.js that works in 3.11.2:

const path = require('path');
const ArcGISPlugin = require("@arcgis/webpack-plugin");

module.exports = {
  mode: 'development',
  entry: {
      main: './app/main.js'
  },
  plugins: [
      new ArcGISPlugin()
  ],
  devServer: {
      contentBase: './'
  }
}

my devDependencies from package.json:

  "devDependencies": {
    "@arcgis/webpack-plugin": "^4.18.0",
    "dojo-typings": "^1.11.11",
    "webpack-cli": "^4.7.2",
    "webpack-dev-server": "^4.0.0-beta.3"

How do I need to update my config to get the latest version working? When I take out the dev server object, the server will run, but serve content out of ./public which doesn't exist.

I'm new to webpack, so I'm not yet familiar with the application, config, and requirements.


Solution

  • devServer: {
      static: './'
    }
    

    I should read the errors more closely. The above object made my config work again.