Skip to content
This repository was archived by the owner on Apr 8, 2020. It is now read-only.

No way to specify webpack 4 "mode" in WebpackDevMiddlewareOptions? #1595

Closed
jakelauer opened this issue Mar 27, 2018 · 3 comments
Closed

No way to specify webpack 4 "mode" in WebpackDevMiddlewareOptions? #1595

jakelauer opened this issue Mar 27, 2018 · 3 comments

Comments

@jakelauer
Copy link

jakelauer commented Mar 27, 2018

I am getting this warning when using WebpackDevMiddleware:

[HMR] bundle has 4 warnings
configuration
The 'mode' option has not been set. Set 'mode' option to 'development' or 'production' to enable defaults for this environment.

I am not seeing a way to specify this flag from WebpackDevMiddlewareOptions. Am I missing something?

@bharney
Copy link

bharney commented Mar 29, 2018

I handled it by just setting mode in both webpack.config files. Below is what I have in the shared portion of each config file.

const sharedConfig = () => ({
        mode: isDevBuild ? 'development' : 'production',
        stats: { modules: false },

That cleared the warning up for me without much change to the configuration. Hope this helps!

@salixzs
Copy link

salixzs commented Apr 1, 2018

To update to WebPack 4, --mode should be specified somehow always, so it may ask for some more drastic changes in all JavaScriptServices and/or middlewares.

--mode development will not do uglifying, map-ing, bundling, cherry-picking and other things it now does automatically for --mode production­. And moreover - production mode now is default (if not speficied). Could be good if JavaScript services could be updated to support Webpack 4, so we get development more goodness with it. As additional - webpack 4 is reported to be considerably faster than previous versions.

Article on Medium.
Another article

On sad note - there are some popular plugins, which got broken on webpack 4, like extract-text-webpack-plugin (now has 4.0.0 alpha release).

@SteveSandersonMS
Copy link
Member

Webpack 4 support is covered by #1562

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants