-
-
Notifications
You must be signed in to change notification settings - Fork 26.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Document maintaining a fork of react-scripts as an alternative to ejecting #682
Comments
I tried this before. (0.2 maybe). But the global cli doesn't install the custom script. Was it fix? |
We are going to be forking react-scripts and attempting to move our build process over to it @trunkclub. I'll talk to the team but I think we could write documentation as we go through the process. |
There was a bug but should be fine with 0.4.3. |
This is supper awesome (...if I understood correctly), Thank you! I'm loving create-react-app, but in the current state it felt like you either embrace it as it is (minimal), or move away. And "Eject" makes you feel like you're being ungrateful with the maintainers. Now with this approach, and in my company, I can be the one maintaining the custom scripts while still keeping my teammates away from the struggle of battling configuration files. For instance, I'd just add less-css support, and still benefit from the core create-react-app features and updates. |
I just run a short custom script after create-react-app does its thing so that I can support CSSModules. All it does is alter two lines in the webpack config scripts (css loader delacarations). Seemed like overkill to fork and publish, but maybe that's the way to go? |
@kirkaustin you don't need to publish it. You can install it directly from github |
@thangngoc89 Not sure I understand. At my company we have an enterprise GitHub account. Are you suggesting that I can have my fork pulled from there? |
You're using npm to install dependencies right? You can do this |
Great, thanks! |
Just curious if anyone has gotten a forked version of react-scripts via direct-from-github npm install working with the most recent With the switch by Previously forking the entire repo (and referencing via github url) worked because So is publishing a custom npm package then the only way to take advantage of this approach? |
So for now I went down the path of using a custom published npm package (like The end result for me is that Edit: after looking at how 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 😃
|
PR to fix this would be welcome. 😉 |
I'm actually in favour of (maybe) just telling people to fork the entire monorepo and publish I wonder if we should suggest people use code to generate their fork, rather than forking by hand. e.g. they could write code like Alternatively, should we just encourage people to hard-fork once create-react-app is sufficiently stable? |
Fixes issue described in #682 (comment).
* Don't hardcode react-scripts package name Fixes issue described in #682 (comment). * Update eject.js
@kirkaustin exactly what I need as well. Will give that option a try. |
This was fixed in 0.5.1, I removed hardcoded project name. |
I want to make a fork for react chrome extensions. @gaearon You say that you can fork react-scripts. But react-scripts is not a git repo. Is the idea that I just copy the code of react-scripts in a new git repo and publish that to github? |
You can fork the whole repo but publish and change that single package. |
Anyone has an idea why this forked version doesn't work? I'm getting the same error as @dpoineau. When I'm changing the npm script in the Probably it's a silly 1 line fix that I'm missing somewhere. EDIT: i fixed this by renaming
🎉 |
Tip to anybody using |
@clessg Ideally we wouldn’t have to do this. Do you have an alternative solution? We could completely get rid of |
I just tried to summarize everything on this topic here: Tweaking Configuration for React Scripts in Create React App. Hope this helps! |
Thanks @shubheksha ! I also just published an article on this topic. |
thank you all, I successfully created a fork of react-scripts and everything works! After all, now, it turns out to be very easy than I thought. Are anyone working to add this to document? @zperrault |
@zperrault quick follow up to your comment here: #682 (comment) Is the solution to run |
@gaearon After reading a lot of resources regarding CRA, I understand that if there is a good way to achieve it with React, it is probably forking the repository and keep merging it with the stable branch In general, I want to enjoy the goodies that CRA has to offer and get updates for free, but in addition, I would like to impose usage of some additional "flavors" that all teams will use. One method I thought about is to fork the repository as described, run create-react-app, and then add some common components and utilities of our company. Looking at above I still cannot answer a number of questions:
Thanks. |
Have a look at my relevant article on Medium. Hope it helps as a starting point. |
Can we have an update on this ? It seems that master still receive day to day udpdates. |
@romaindso we no longer will perform major tl;dr maintain your fork off |
@g3r4n did you every get it working? I am getting this error:
when trying to use the alpha for 2.0.0. |
* Don't hardcode react-scripts package name Fixes issue described in facebook/create-react-app#682 (comment). * Update eject.js
Is this still a viable solution/alternative to eject? How would I add a fork of react-scripts to an existing project created with CRA? The command line doesn't seem to update/overwrite configs in an existing project. Also, when starting anew I'm also getting |
I got it working. I had to publish forks of each package and had to update all internal references to point at my packages. It’s a pain but I’m just maintaining it until 2.0 drops officially. Unfortunately it has enough custom parts I cannot publish publicly but could contribute to your fork if you have a place you want to work out of. |
Ouch! I see. Is there any way to update an existing project with a fork? We just started a project a couple of weeks ago via CRA and I need to make the smallest tweak to the webpack configs. I feel like I'm firing up a 747 just to visit my next door neighbor with this approach but I'm doing what I can to make things run. |
Also, does each fork need to have its package name updated to be different from the official repo? |
… On September 13, 2018 at 6:40:12 PM, Clifton ***@***.***) wrote:
Ouch! I see. Is there any way to update an existing project with a fork?
We just started a project a couple of weeks ago via CRA and I need to make
the smallest tweak to the webpack configs. I feel like I'm firing up a 747
just to visit my next door neighbor with this approach but I'm doing what I
can to make things run.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#682 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAGpirawJ9ArTtGkjtVzGbH8_zZ3aEBWks5uauzcgaJpZM4KAY6J>
.
|
I saw this earlier and lost the link! Does it actually work? I'll have to give it a shot. Thanks! |
By the way, that works like a charm, thanks! |
I agree react-app-rewired was a great solution before CRA2. But CRA2 uses webpack 4, which breaks most plugins. Also its maintainer is apparently retiring[1], so this remains a thorny problem. |
It seems that I have some trouble. |
@ubbcou publish it as a scoped package, like |
I tried to use a fork of react-scripts with |
Well, after diving into the code, I noticed that there paths.js module that exports different path values based on some assumptions, one of them being published, for which it tries to evaluate if the app's node_modules contains the react-scripts package, but apparently this doesn't work with symlinks created with So what I've done to avoid publishing to npm each time I wanted to try something in my app, was to install my custom react-scripts from my file system with the following command:
This works, but the downside is that you have to run the command each time you make a modification of the your custom react-scripts. It would be awesome if we could use |
It is not common knowledge that you can fork
react-scripts
, publish your fork, and then docreate-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!
The text was updated successfully, but these errors were encountered: