Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kitze/custom-react-scripts
[DEPRECATED, use customize-cra] Allow custom config for create-react-app without ejecting
https://github.com/kitze/custom-react-scripts
babel config create-react-app custom-config fork webpack
Last synced: 3 months ago
JSON representation
[DEPRECATED, use customize-cra] Allow custom config for create-react-app without ejecting
- Host: GitHub
- URL: https://github.com/kitze/custom-react-scripts
- Owner: kitze
- License: mit
- Fork: true (facebook/create-react-app)
- Created: 2016-09-24T09:56:20.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2023-05-25T15:07:50.000Z (over 1 year ago)
- Last Synced: 2024-04-14T00:24:16.602Z (8 months ago)
- Topics: babel, config, create-react-app, custom-config, fork, webpack
- Language: JavaScript
- Homepage: https://custom-react-scripts.netlify.com
- Size: 5.19 MB
- Stars: 996
- Watchers: 28
- Forks: 98
- Open Issues: 44
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG-0.x.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
### ๐โโ๏ธ Made by [@thekitze](https://twitter.com/thekitze)
### Other projects:
- ๐ป [Sizzy](https://sizzy.co) - A browser for designers and developers, focused on responsive design
- ๐ซ [React Academy](https://reactacademy.io) - Interactive React and GraphQL workshops
- ๐ฎ [Glink](https://glink.so) - Changelogs, Roadmap, User Requests
- ๐ถ [Benji](https://benji.so) - Ultimate wellness and productivity platform
- ๐ค [JSUI](https://github.com/kitze/JSUI) - A powerful UI toolkit for managing JavaScript apps
- ๐น [YouTube Vlog](https://youtube.com/kitze) - Follow my journey---
โ ๏ธ This repo is **deprecated**.
Please use [react-app-rewired](https://github.com/timarney/react-app-rewired) if you want to customize CRA 1.
Please use [customize-cra](https://github.com/arackaf/customize-cra) if you want to customize CRA 2.# โข custom-react-scripts โข
Latest version of original react-scripts: **1.1.14**### โ ๏ธ Disclaimer:
> This is **not** a fork of ```create-react-app```. It's just a fork of ```react-scripts``` with simple babel/webpack modifications that can toggle extra features.The reason for this fork's existence is explained better in [this Medium article](https://medium.com/@kitze/configure-create-react-app-without-ejecting-d8450e96196a).
### ๐กFeatures:
* Decorators
* babel-preset-stage-0
* Less
* Sass
* CSS modules
* Sass modules
* Less modules
* Stylus modules**the features are optional and can be turned on/off individually*
### โHow to use it
```create-react-app my-app --scripts-version custom-react-scripts```Modify the `.env` file in the root of the generated project, and add any of the configuration options below ๐ to enable that feature.
The generated project comes with every option turned on by default, but you can remove them at any time by removing the options from the ```.env``` file.
#### Adding to an existing project
```
npm uninstall --save react-scripts;
npm install --save custom-react-scripts;
```Add a `.env.` file with the desired features.
### ๐ Configuration options
#### Styling
- ```REACT_APP_SASS=true``` - enable SASS support
- ```REACT_APP_LESS=true``` - enable LESS support
- ```REACT_APP_STYLUS=true``` - enable Stylus support
- ```REACT_APP_CSS_MODULES=true``` - enable CSS modules
- ```REACT_APP_SASS_MODULES=true``` - enable Sass modules
- ```REACT_APP_LESS_MODULES=true``` - enable Less modules
- ```REACT_APP_STYLUS_MODULES=true``` - enable Stylus modules
- ```REACT_APP_CSS_MODULE_CLASSNAME_TEMPLATE='module-[sha512:hash:base32]-[name]-[local]'``` - add custom CSS Module hash ident nameNote: to use modules the file must be named in the following format: ```$name.module.$preprocessorName```.
For example ```styles.module.css``` or ```header.module.sass``` or ```footer.module.less```, etc. Files that are not prefixed with module will be parsed normally.
#### Babel
- ```REACT_APP_BABEL_STAGE_0=true``` - enable stage-0 Babel preset
- ```REACT_APP_DECORATORS=true``` - enable decorators support#### Other
- ```REACT_APP_WEBPACK_DASHBOARD=true``` - Enables connection to the [webpack-dashboard](https://github.com/FormidableLabs/electron-webpack-dashboard) Electron app (the app must be installed on local machine)### ๐ค Why?
The ```create-react-app``` app doesn't allow user configuration and modifications for few reasons:* Some of the babel presets and plugins that people might use are experimental. If they're used in a project and then they don't make it in the ES spec, they will break backwards compatibility.
* It's hard to maintain code for all of these custom configurations that people want to use.But people still want to use some of these features, and they're either ejecting their CRA app, or just don't use ```create-react-app``` because they're *just* missing **X** feature.
So instead of [searching npm](https://www.npmjs.com/search?q=react-scripts) for a ```react-scripts``` fork with the **X** feature you need, this fork provides support for all of these extra features with simply adding a line in the ```.env``` config.
### How does it work?
The CRA team recently [added support](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#adding-development-environment-variables-in-env) for an ```.env``` file in the root of the generated CRA project.From the original readme:
> To define permanent environment vairables, create a file called .env in the root of your project:
> ```REACT_APP_SECRET_CODE=abcdef```I just added support for extra environment variables that actually turn on certain plugins, babel plugins, presets, and loaders in the webpack and babel configs of ```react-scripts```.
### Future plans
I will put all of my efforts into supporting this fork to be always on par with features with the newest ```create-react-app``` and ```react-scripts``` versions.