Search code examples
expresswebpackwebpack-dev-serverwebpack-dev-middlewarewebpack-4

How can I set the webpack --mode using webpack-dev-middleware?


I have an express server that runs my app using webpack-dev-middleware and webpack-dev-server.

After updating to [email protected] I get the following warning

WARNING in configuration
The 'mode' option has not been set. Set 'mode' option to 'development' or 'production' to enable defaults for this environment.

Since I am not directly running webpack from the CLI how can set the --mode option?


Solution

  • The mode option can also be set in the webpack config object:

    {
        mode: 'development'
    }
    

    More related info configuring Webpack 4 can be found in this webpack-demo