0

I've seen two in the docs ...

https://webpack.js.org/configuration/mode/

version 1

webpack --mode=development

and

https://webpack.js.org/api/cli/

version 2

npx webpack --mode development

One has the equal sign and one does not. If they are both correct, which is preferred?

howard
  • 234
  • 1
  • 11
  • This is rather a question of `commander` since `webpack-cli` uses that. Their readme does seem to indicate that they are the same. As to which one is better, well... there could be multiple opinions about that. – MinusFour Sep 16 '21 at 02:33
  • Kind of annoying that they switch back and forth in the docs ... would be nice if they picked one or the other for consistency. – howard Sep 16 '21 at 02:44

1 Answers1

0

The short answer is no difference between 2 of those and both are correct.

Without webpack-cli you cannot execute both variants. The only difference between those examples is whether webpack-cli was installed as a global package. If you previously installed it with -g flag then the first option (without npx) is available, otherwise you can always use 2nd option.

Dmitriy Ievlev
  • 191
  • 3
  • 6
  • So which version does webpack-cli enable? the first our the second? Q updated. – howard Sep 17 '21 at 00:02
  • webpack-cli package is required for both. 0) if you do not have this package installed, then both options will not work. 1) If you installed webpack-cli package as 'npm install -g webpack-cli', then 1st option is possible 2) If you installed webpack-cli package as 'npm install webpack-cli', then 2nd option is possible inside a folder containing package.json – Dmitriy Ievlev Sep 17 '21 at 07:59