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.

Is there a way to prevent load of react-scripts for webpack.config.js?

See original GitHub issue

Is your feature request related to a problem? Please describe. I have a custom config for storybook using the full-control mode. I now have a sibling package in a lerna monorepo that uses react-scripts, but this is not used or wanted in my storybook package, and I’d like to avoid loading this config for storybook at all, as the rules conflict and I need much more control over the storybook config than what react-scripts offers for this use-case. React-scripts is being hoisted by lerna into the root node_modules directory, which results in this config being loaded for use when running the storybook and build-storybook scripts. From what I understand, this is because it is found in the root node_modules.

Describe the solution you’d like I would either like a way to disable the load of react-scripts config completely—perhaps a cli flag or a way to get and extend only the base minimum config used for storybook in webpack.config.js (before all the config is added by react-scripts).

Describe alternatives you’ve considered I considered preventing react-scripts from being hoisted to the root node_modules, but this isn’t a good option because it has the potential to be used by many other leaf packages that could be added to this monorepo and therefore would be best held in the root n_m.

Are you able to assist bring the feature to reality? I’m writing this in hopes there is already a supported way to achieve my goal without having to take the storybookBaseConfig in webpack.config.js and do a lot of tedious filtering of the rules that are being added from react-scripts. It would be a much cleaner solution to simply prevent the load of react-scripts from the start. If there is no way currently for this to be done, maybe we can talk about some options and the best way forward for a potential new feature.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:11 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
shilmancommented, Jun 24, 2019

@mrmckeb for a little color here, we’ve already started adding presets for scss and typescript, and it seems to be working well.

I can imagine doing the same for CRA compat. We’d automatically add it to the user’s presets.js file if CRA is detected by the CLI, and if it didn’t get detected users could add it manually (and could potentially configure it also–something that’s not possible right now).

This is a breaking change, so we wouldn’t be able to introduce it until 6.0. But I think we should consider it!

1reaction
shilmancommented, Jun 5, 2019

I’ve run across this too. Perhaps we can do a check in package.json instead of or in addition to the existing check. What do you think @mrmckeb ?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Overriding the Create-React-App Webpack Configuration ...
If you have access to the Webpack configuration, disabling name mangling is just a matter of changing 2 lines of code: // in...
Read more >
The best webpack configurations for React applications
Bundling and minifying of scripts and stylesheets; Optimizations such as code-splitting and lazy-loading. Prerequisites for setting up webpack.
Read more >
How to avoid `loaded two copies of React` error when ...
The issue is twofold: You cannot have 2 copies of react loaded. npm link creates a symlink, however the "require" doesnt respect the...
Read more >
Complete Guide to Webpack Configuration for React
First, in our project directory create a dist folder which will hold all of our webpack compiled scripts and our main entry javascript...
Read more >
Two Quick Ways To Reduce React App's Size In Production
2. Import the plugin to webpack.config.prod.js · 3. Add it to plugins array · 4. Finally, add this middleware to Express to return...
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