2

I understand that the webpack package and the webpack-cli package both need to be installed in order to use webpack commands. I understand that in webpack 3 there was just one package and it contained the command line functionality, but in webpack 4 the command line functionality has been separated out into its own package. However, both webpack and webpack-cli work on the command line, and they seem to do the same thing. I tried looking into the source code a bit and the two commands eventually seem to call the same function, but they do it in two different roundabout ways rather than having one simply call the other or be an alias for the other. This makes me second guess myself.

I can't find any information online that compares these two commands. All the information I could find seems to be talking about the packages rather than the commands themselves, and it's easy to conflate the webpack-cli package with the idea of running webpack itself from the CLI. So which one should I use?

Kyle Delaney
  • 11,616
  • 6
  • 39
  • 66

1 Answers1

1

When you execute node_modules\.bin\webpack build or npx webpack build, you underlying call node_modules\.bin\webpack-cli build actually. If you don't install webpack-cli, you will find you can't execute webpack xxx command, and it will prompt you install the webpack-cli.