webpack 4: access the mode flag from webpack.config.js file
See original GitHub issueDo you want to request a feature or report a bug?
feature
If this is a feature request, what is motivation or use case for changing the behavior?
Since webpack 4 introduces an official --mode
it’d be nice to be able to access it, otherwise I’m back to the old process.env.NODE_ENV === 'production'
if I want to customize the production build, like for https://github.com/webpack/webpack/issues/6409#issuecomment-361636056
Please mention other relevant information such as the browser version, Node.js version, webpack version and Operating System.
webpack 4.0.0-beta.0
Issue Analytics
- State:
- Created 6 years ago
- Reactions:48
- Comments:40 (9 by maintainers)
Top Results From Across the Web
Mode | webpack
Its main purpose is to bundle JavaScript files for usage in a browser, ... Providing the mode configuration option tells webpack to use...
Read more >Get current `--mode` in webpack.config.js - Stack Overflow
How can I get the current --mode specified in package.json inside webpack.config.js? (For instance, for pushing some plugins.)
Read more >How to read mode in webpack.config.js - How to dev
Webpack works with many approaches to the configuration file. One of the allowed forms is configuration function. This approach is a bit more ......
Read more >webpack 4 - How to have separate build outputs ... - Ed Spencer
In your webpack.config.js file, it's not possible to detect this mode flag, and to then conditionally add the plugin based on this flag....
Read more >All You Need to Know about Webpack in Examples - Medium
js file. For specifying another config file that our server should use before start: npx webpack-dev-server --config webpack.common.js.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
This seems to work correctly with
--mode production
,-p
and<no flag>
. 🎉 for normalizedargv
Are there any caveats to using a function? Like subtle changes of behavior?
Just to clarify for all those a little who need a little extra explanation (I fall into that camp).
webpack.config.js