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.

Document maintaining a fork of react-scripts as an alternative to ejecting

See original GitHub issue

It is not common knowledge that you can fork react-scripts, publish your fork, and then do create-react-app my-app --scripts-version my-react-scripts-fork.

This can be useful for customized setups, especially if you want to merge upstream updates once in a while. And with something like https://github.com/1egoman/backstroke, it might not even be painful!

We should document this. Help welcome!

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:122
  • Comments:85 (32 by maintainers)

github_iconTop GitHub Comments

23reactions
thangngoc89commented, Sep 19, 2016

You’re using npm to install dependencies right? You can do this npm install git+ssh://git@github.com/your-company/react-scripts-fork . You don’t need to publish the scripts to npm and then install it.

21reactions
dpoineaucommented, Sep 22, 2016

So for now I went down the path of using a custom published npm package (like react-scripts-custom-whatever), but it still seems like there’s at least one issue that prevents this from working which is that the react-scripts package name is hardcoded in at least one spot, which won’t work if you’re using a custom forked package: https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/scripts/init.js#L17

The end result for me is that create-react-app fails at executing the init script. Has anyone been successful with this approach with the most recent version of react-scripts (0.4.3), and I’m just doing something wrong?

Edit: after looking at how e2e.sh runs its --scripts-version react-scripts-fork test successfully, it looks like the solution used in that fork was to just change the hardcoded package name in the line I referenced above in the fork to be the forked package name.

Last edit: Here are all the steps I used to get a custom fork working in case anyone else gets as stuck as I did 😃

  1. Forked the create-react-app repo and cloned it locally
  2. Changed the package name in packages/react-scripts/package.json to be a new custom name
  3. Changed the ‘react-scripts’ reference in packages/react-scripts/scripts/init.js#L17 to match the new package name I chose
  4. Then I did a cd packages/react-scripts followed by an npm publish which published successfully
  5. Which then resulted in create-react-app test-app --scripts-version react-scripts-my-custom-package working as expected
Read more comments on GitHub >

github_iconTop Results From Across the Web

Maintaining a fork of create-react-app as an alternative to ...
You either accept and steer your workflow, or search for other options. Solution #1: eject. One possible solution is the official and documented ......
Read more >
Alternatives to Ejecting - Create React App
In such cases instead of ejecting we recommend to fork react-scripts and any other packages you need. This article covers how to do...
Read more >
Everything you need to know about react-scripts
Running the eject script will remove the single build dependency from your project. That means it will copy the configuration files and the ......
Read more >
What does this "react-scripts eject" command do?
Ejecting lets you customize anything, but from that point on you have to maintain the configuration and scripts yourself. This can be daunting ......
Read more >
Customizing Create React App — Done Right - codeburst
Ejecting lets you customize anything, but from that point on you have to maintain the configuration and scripts yourself.
Read more >

github_iconTop Related Medium Post

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