Add a plugin to webpack config w/o ejecting
See original GitHub issueIs that possible? I’m using moment and it loads all the locales (so moment takes 200kB instead of 50kB in the build), the current fix for more than one year seems to be to exclude the locales via webpack using:
new webpack.ContextReplacementPlugin(/moment[\\\/]locale$/, /^\.\/(en)$/)
I tried to add it manually to /node_modules/react-scripts/config/webpack.config.prod.js
and it works but I can’t do that, and I don’t want to eject.
Issue Analytics
- State:
- Created 7 years ago
- Reactions:3
- Comments:13 (9 by maintainers)
Top Results From Across the Web
Overriding the Create-React-App Webpack Configuration ...
Create-React-App is a great tool to bootstrap React apps, but it offers only limited access to the configuration of the production build.
Read more >How can I add the CopyWebpackPlugin to create-react-app ...
I am getting no errors and no files are being copied. This is my config-overrides.js const CopyWebpackPlugin = require('copy-webpack- ...
Read more >Ejecting `create-react-app` to Support Multiple Scripts in a ...
I'm working on a little chrome extension, called “you should check out” (ysco), which will show visitors to a website other resources that ......
Read more >Bundling with webpack - Expo Documentation
If you need to edit the config the best way to do this is by running npx expo customize webpack.config.js . This will...
Read more >Ejecting webpack · Cloudflare Workers docs
I use type = webpack , but do not provide my own configuration and let ... Add wranglerjs-compat-webpack-plugin to webpack.config.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
FWIW if you need something similar to Moment but not suffering from this issue, I recommend date-fns.
I’d suggest that no one ever wants to bundle a 115 locales at once. The Ignore would just prevent them from being bundled automatically (as far as I’ve seen) when you require
moment
. You can stillimport
/require
frommoment/locales/en-GB
explicitly in the your app for the locales you want.