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.

Add a plugin to webpack config w/o ejecting

See original GitHub issue

Is 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.jsand it works but I can’t do that, and I don’t want to eject.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:3
  • Comments:13 (9 by maintainers)

github_iconTop GitHub Comments

4reactions
gaearoncommented, Nov 18, 2016

FWIW if you need something similar to Moment but not suffering from this issue, I recommend date-fns.

1reaction
jquensecommented, Apr 27, 2017

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 still import/require from moment/locales/en-GB explicitly in the your app for the locales you want.

Read more comments on GitHub >

github_iconTop 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 >

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