question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Minimalize differences between CLI and Node.js API and move CLI in `webpack-cli`

See original GitHub issue

There 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:closed
  • Created 7 years ago
  • Reactions:11
  • Comments:13 (6 by maintainers)

github_iconTop GitHub Comments

3reactions
obedm503commented, Jan 16, 2018

#994 is still an issue, lack of uniformity between cli and node api is a huge issue for webpack noobs like me

2reactions
the-spykecommented, Dec 15, 2017

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. But bin/webpack-dev-server.js is doing too much work. It will be cool to extract processOptions() and startDevServer() into separate file(s), so anybody can reuse them. The only logic left in the actual binary will be argv parsing.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Command Line Interface - webpack
webpack is a module bundler. Its main purpose is to bundle JavaScript files for usage in a browser, yet it is also capable...
Read more >
To v4 from v3 - webpack
CLI. The CLI has moved to a separate package: webpack-cli. You need to install it before using webpack, see basic setup. The installation...
Read more >
To v5 from v4 - webpack
This guide aims to help you migrating to webpack 5 when using webpack directly. If you are using a higher level tool to...
Read more >
Build Performance - webpack
This guide contains some useful tips for improving build/compilation performance. General. The following best practices should help, whether you're running ...
Read more >
Optimization - webpack
By default, a minimum length of 3 digits is used when optimization. ... If you are using webpack CLI, the webpack process will...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found