Document maintaining a fork of react-scripts as an alternative to ejecting
See original GitHub issueIt 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:
- Created 7 years ago
- Reactions:122
- Comments:85 (32 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
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
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
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.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 thereact-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#L17The end result for me is that
create-react-app
fails at executing theinit
script. Has anyone been successful with this approach with the most recent version ofreact-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 😃
create-react-app
repo and cloned it locallypackages/react-scripts/package.json
to be a new custom namepackages/react-scripts/scripts/init.js#L17
to match the new package name I chosecd packages/react-scripts
followed by annpm publish
which published successfullycreate-react-app test-app --scripts-version react-scripts-my-custom-package
working as expected