[6.x] Add Webpack rules per environment basis (using the Webpack template)
See original GitHub issue- I have read the contribution documentation for this project.
- I agree to follow the code of conduct that this project follows, as appropriate.
- I have searched the issue tracker for an issue that matches the one I want to file, without success.
Please describe your issue:
I’ve setup a small project using electron-forge, version 6. I’ve added css-loader, style-loader and mini-css-extract-plugin to my project in order to import css files and resolve them properly.
However, style-loader
is only relevant in development and the mini-css-extract-plugin
is only relevant in production. Since I only have one entrypoint per process, how do I separate configuration between environments?
According to the documentation, I shouldn’t need to care, but in this case I do need to care. Is there any example or guidelines for how one go about adding environment specific options using the Webpack template?
Issue Analytics
- State:
- Created 4 years ago
- Reactions:3
- Comments:11 (4 by maintainers)
Top Results From Across the Web
[6.x] Add Webpack rules per environment basis (using the ...
Is there any example or guidelines for how one go about adding environment specific options using the Webpack template?
Read more >Module | webpack - JS.ORG
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 >webpack Tutorial: How to Set Up webpack 5 From Scratch
Create a plugins property of your config and you'll add the plugin, filename to output ( index.html ), and link to the template...
Read more >How to customize webpack in Rails apps - rossta.net
Still, the base webpack configuration provided by ... for all Rails environments, so is config/webpack/environment.js for each of the ...
Read more >Creating a React app with Webpack - JavaScript Ramblings
Add Webpack and bundle a simple JS file; Add Babel for ES6 support; Add React. Without further ado, let's get started! Step 1:...
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 FreeTop 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
Top GitHub Comments
There’s other benefits to indicating production vs development. The most recent version of webpack uses a “mode” flag (see https://webpack.js.org/configuration/mode/) which runs some good optimizations based on the environment.
This can greatly impact the performance of a production app and is pretty much the only reason I use webpack.
I think some of the plugins it mentions like the TerserPlugin are really important to configure well as well.
@MarshallOfSound thanks for the quick response.
I’m not entirely sure what you’re saying here. Are you asking me if using
process.env.NODE_ENV
would be enough if it reflected the current environment? If so, the short answer is yes.I see. Would it be of interested supporting the behavior? It would align nicely with how Webpack currently works and make the transitions easier for people already using it. I’d be up for helping out with a pull request if we decide to move forward with that approach. 🙂