-
-
Notifications
You must be signed in to change notification settings - Fork 27.2k
Document forking react-scripts instead of ejecting #779
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
Changes from 1 commit
90220fb
8bac1c5
aaa255d
83d092f
10ead31
c27cd91
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -48,6 +48,7 @@ You can find the most recent version of this guide [here](https://github.com/fac | |
| - [Modulus](#modulus) | ||
| - [Now](#now) | ||
| - [Surge](#surge) | ||
| - [Fork instead of eject](#fork-instead-of-eject) | ||
| - [Something Missing?](#something-missing) | ||
|
|
||
| ## Updating to New Releases | ||
|
|
@@ -936,6 +937,50 @@ Install the Surge CLI if you haven't already by running `npm install -g surge`. | |
|
|
||
| Note that in order to support routers that use html5 `pushState` API, you may want to rename the `index.html` in your build folder to `200.html` before deploying to Surge. This [ensures that every URL falls back to that file](https://surge.sh/help/adding-a-200-page-for-client-side-routing). | ||
|
|
||
| ## Fork instead of eject | ||
|
|
||
| If you want to customize the default configuration slightly (e.g. add CSS Modules, SASS, decorators…), while still having all future updates and a one dependency, you can fork this repo and create your own configuration of `react-scripts` and use it with `create-react-app`. | ||
|
||
|
|
||
| ### Instruction | ||
|
||
|
|
||
| 1: Fork [create-react-app repo](https://github.com/facebookincubator/create-react-app). | ||
|
||
|
|
||
| 2: Change the name of `react-scripts` package to your new one, and also reset its version. | ||
|
||
| ```js | ||
| // /packages/react-scripts/package.json | ||
|
||
| { | ||
| "name": "my-react-scripts-fork", | ||
| "version": "0.0.1", | ||
| … | ||
| } | ||
| ``` | ||
|
|
||
| 3: Make your changes inside `react-scripts` package. For example, add CSS Modules: | ||
| ```js | ||
| // /packages/react-scripts/config/webpack.config.dev.js | ||
|
||
| … | ||
| { | ||
| test: /\.css$/, | ||
| loader: 'style!css?modules=1!postcss' | ||
| }, | ||
| … | ||
| ``` | ||
|
|
||
| 4: [Publish](https://docs.npmjs.com/getting-started/publishing-npm-packages) your customized `react-scripts` package to npm. Remember to cd into `/packages/react-scripts/` before you publish. | ||
| ```sh | ||
| $ cd packages/react-scripts | ||
| $ npm publish | ||
|
||
| ``` | ||
|
|
||
| 5: Now you can use your customized setup with `create react app`: | ||
|
||
| ```sh | ||
| $ create-react-app my-app --scripts-version my-react-scripts-fork | ||
| ``` | ||
|
|
||
| ### Note | ||
| - [create-react-app](https://github.com/facebookincubator/create-react-app) is a [monorepo](https://github.com/babel/babel/blob/master/doc/design/monorepo.md) that contains `react-scripts` package. This is the heart of CRA, with all configurations and scripts. You only need to change and publish this package, not the whole repo. | ||
|
||
| - It is recommended to [keep your fork synced](https://help.github.com/articles/fork-a-repo/#keep-your-fork-synced) with the upstream updates. [Backstroke](https://github.com/1egoman/backstroke) is a bot to help you with this. | ||
|
|
||
| ## Something Missing? | ||
|
|
||
| If you have ideas for more “How To” recipes that should be on this page, [let us know](https://github.com/facebookincubator/create-react-app/issues) or [contribute some!](https://github.com/facebookincubator/create-react-app/edit/master/packages/react-scripts/template/README.md) | ||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let’s call this
Forking as Alternative to Ejecting, with capitalized words.