Skip to content Skip to sidebar Skip to footer

Why Is Webpack-dev-server Throwing An Error When I Use --arg?

This is my script: 'dev': 'webpack-dev-server --inline --progress --config build/webpack.dev.conf.js --arg devus' In my old setup I used to do: 'dev': 'node build/dev-server.js --

Solution 1:

The thing you described was possible with webpack 1.

As of webpack 2+ (and webpack-dev-server will pass the arguments to the webpack as is) passing the custom arguments can be done only by prefixing the arguments with env.:

"dev":"webpack-dev-server --inline --progress --config build/webpack.dev.conf.js --env.arg devus"

However your script will not work as is, you would need to adapt it to use env property inside of your webpack configuration.

In other words this is how your config should look like

module.exports = env => {
  console.log(env);

  return {
    // your config heree
  }
};

See the documentation

Post a Comment for "Why Is Webpack-dev-server Throwing An Error When I Use --arg?"