Minimalize differences between CLI and Node.js API and move CLI in `webpack-cli`
See original GitHub issueThere are some differences between the CLI and Node.js API that make webpack-dev-server a lot harder to use for people. Most differences are documented in the wiki, but users often don’t look at this. They also shouldn’t have to.
The first problem is that the CLI in inline modus (which is the default since v2), automatically adds an entry to the webpack config. When you use the API, you need to do this manually. What makes it more confusing is that there is is a inline option, but that only has effect when using the CLI.
The second problem is that, when using --hot, the CLI adds an entry to the webpack config and adds the HotModuleReplacementPlugin. In the API, you need to add those two things yourself, as well as set hot: true.
The idea was that the API shouldn’t mutate the webpack config. This is indeed iffy, but perhaps there are other ways to do this without mutating the config. Or if there is not, maybe it’s worth it to mutate the config? The current situation causes many issues with users.
Related to #106, but that discussion is quite old and not all points are valid anymore.
cc @bebraw
Issue Analytics
- State:
- Created 7 years ago
- Reactions:11
- Comments:13 (6 by maintainers)

Top Related StackOverflow Question
#994 is still an issue, lack of uniformity between cli and node api is a huge issue for webpack noobs like me
I’ve tried to run WDS from my own CLI, but I can’t make it behave the same way as running the binary directly. Using the
examples/api/simple/with my regular config file doesn’t give me page reloading, etc. I’d also like to see console output I got used to: host, history api, etc. Butbin/webpack-dev-server.jsis doing too much work. It will be cool to extractprocessOptions()andstartDevServer()into separate file(s), so anybody can reuse them. The only logic left in the actual binary will beargvparsing.