diff --git a/.gitignore b/.gitignore
index 79ce88915d7..da0b2163db7 100644
--- a/.gitignore
+++ b/.gitignore
@@ -11,3 +11,5 @@ npm-debug.log*
yarn-debug.log*
yarn-error.log*
/.changelog
+yarn.lock
+.idea
\ No newline at end of file
diff --git a/README.md b/README.md
index b09630e90ba..1fa8ebccd04 100644
--- a/README.md
+++ b/README.md
@@ -1,224 +1,100 @@
-# Create React App [](https://travis-ci.org/facebookincubator/create-react-app)
+### ๐โโ๏ธ Made by [@thekitze](https://twitter.com/thekitze)
-Create React apps with no build configuration.
+### 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
-* [Creating an App](#creating-an-app) โ How to create a new app.
-* [User Guide](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md) โ How to develop apps bootstrapped with Create React App.
+
-Create React App works on macOS, Windows, and Linux.
-If something doesnโt work, please [file an issue](https://github.com/facebookincubator/create-react-app/issues/new).
+---
-## Quick Overview
+โ ๏ธ This repo is **deprecated**.
-```sh
-npx create-react-app my-app
-cd my-app
-npm start
-```
-
-*([npx](https://medium.com/@maybekatz/introducing-npx-an-npm-package-runner-55f7d4bd282b) comes with npm 5.2+ and higher, see [instructions for older npm versions](https://gist.github.com/gaearon/4064d3c23a77c74a3614c498a8bb1c5f))*
-
-Then open [http://localhost:3000/](http://localhost:3000/) to see your app.
-When youโre ready to deploy to production, create a minified bundle with `npm run build`.
+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**
-### Get Started Immediately
+### โ ๏ธ 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.
-You **donโt** need to install or configure tools like Webpack or Babel.
-They are preconfigured and hidden so that you can focus on the code.
+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).
-Just create a project, and youโre good to go.
+### ๐กFeatures:
+* Decorators
+* babel-preset-stage-0
+* Less
+* Sass
+* CSS modules
+* Sass modules
+* Less modules
+* Stylus modules
-## Creating an App
+**the features are optional and can be turned on/off individually*
-**Youโll need to have Node >= 6 on your local development machine** (but itโs not required on the server). You can use [nvm](https://github.com/creationix/nvm#installation) (macOS/Linux) or [nvm-windows](https://github.com/coreybutler/nvm-windows#node-version-manager-nvm-for-windows) to easily switch Node versions between different projects.
+### โHow to use it
+```create-react-app my-app --scripts-version custom-react-scripts```
-To create a new app, run a single command:
-
-```sh
-npx create-react-app my-app
-```
+Modify the `.env` file in the root of the generated project, and add any of the configuration options below ๐ to enable that feature.
-*([npx](https://medium.com/@maybekatz/introducing-npx-an-npm-package-runner-55f7d4bd282b) comes with npm 5.2+ and higher, see [instructions for older npm versions](https://gist.github.com/gaearon/4064d3c23a77c74a3614c498a8bb1c5f))*
+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.
-It will create a directory called `my-app` inside the current folder.
-Inside that directory, it will generate the initial project structure and install the transitive dependencies:
+#### Adding to an existing project
```
-my-app
-โโโ README.md
-โโโ node_modules
-โโโ package.json
-โโโ .gitignore
-โโโ public
-โ โโโ favicon.ico
-โ โโโ index.html
-โ โโโ manifest.json
-โโโ src
- โโโ App.css
- โโโ App.js
- โโโ App.test.js
- โโโ index.css
- โโโ index.js
- โโโ logo.svg
- โโโ registerServiceWorker.js
+npm uninstall --save react-scripts;
+npm install --save custom-react-scripts;
```
-No configuration or complicated folder structures, just the files you need to build your app.
-Once the installation is done, you can open your project folder:
-
-```sh
-cd my-app
-```
-
-Inside the newly created project, you can run some built-in commands:
-
-### `npm start` or `yarn start`
-
-Runs the app in development mode.
-Open [http://localhost:3000](http://localhost:3000) to view it in the browser.
-
-The page will automatically reload if you make changes to the code.
-You will see the build errors and lint warnings in the console.
-
-
-
-### `npm test` or `yarn test`
-
-Runs the test watcher in an interactive mode.
-By default, runs tests related to files changed since the last commit.
-
-[Read more about testing.](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#running-tests)
-
-### `npm run build` or `yarn build`
-
-Builds the app for production to the `build` folder.
-It correctly bundles React in production mode and optimizes the build for the best performance.
-
-The build is minified and the filenames include the hashes.
-By default, it also [includes a service worker](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#making-a-progressive-web-app) so that your app loads from local cache on future visits.
-
-Your app is ready to be deployed.
-
-## User Guide
-
-The [User Guide](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md) includes information on different topics, such as:
-
-- [Updating to New Releases](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#updating-to-new-releases)
-- [Folder Structure](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#folder-structure)
-- [Available Scripts](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#available-scripts)
-- [Supported Browsers](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#supported-browsers)
-- [Supported Language Features and Polyfills](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#supported-language-features-and-polyfills)
-- [Syntax Highlighting in the Editor](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#syntax-highlighting-in-the-editor)
-- [Displaying Lint Output in the Editor](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#displaying-lint-output-in-the-editor)
-- [Formatting Code Automatically](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#formatting-code-automatically)
-- [Debugging in the Editor](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#debugging-in-the-editor)
-- [Changing the Page ``](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#changing-the-page-title)
-- [Installing a Dependency](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#installing-a-dependency)
-- [Importing a Component](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#importing-a-component)
-- [Code Splitting](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#code-splitting)
-- [Adding a Stylesheet](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#adding-a-stylesheet)
-- [Post-Processing CSS](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#post-processing-css)
-- [Adding a CSS Preprocessor (Sass, Less etc.)](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#adding-a-css-preprocessor-sass-less-etc)
-- [Adding Images, Fonts, and Files](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#adding-images-fonts-and-files)
-- [Using the `public` Folder](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#using-the-public-folder)
-- [Using Global Variables](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#using-global-variables)
-- [Adding Bootstrap](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#adding-bootstrap)
-- [Adding Flow](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#adding-flow)
-- [Adding a Router](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#adding-a-router)
-- [Adding Custom Environment Variables](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#adding-custom-environment-variables)
-- [Can I Use Decorators?](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#can-i-use-decorators)
-- [Fetching Data with AJAX Requests](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#fetching-data-with-ajax-requests)
-- [Integrating with an API Backend](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#integrating-with-an-api-backend)
-- [Proxying API Requests in Development](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#proxying-api-requests-in-development)
-- [Using HTTPS in Development](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#using-https-in-development)
-- [Generating Dynamic `` Tags on the Server](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#generating-dynamic-meta-tags-on-the-server)
-- [Pre-Rendering into Static HTML Files](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#pre-rendering-into-static-html-files)
-- [Running Tests](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#running-tests)
-- [Debugging Tests](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#debugging-tests)
-- [Developing Components in Isolation](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#developing-components-in-isolation)
-- [Publishing Components to npm](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#publishing-components-to-npm)
-- [Making a Progressive Web App](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#making-a-progressive-web-app)
-- [Analyzing the Bundle Size](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#analyzing-the-bundle-size)
-- [Deployment](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#deployment)
-- [Advanced Configuration](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#advanced-configuration)
-- [Troubleshooting](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#troubleshooting)
-
-A copy of the user guide will be created as `README.md` in your project folder.
-
-## How to Update to New Versions?
-
-Please refer to the [User Guide](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#updating-to-new-releases) for this and other information.
-
-## Philosophy
-
-* **One Dependency:** There is just one build dependency. It uses Webpack, Babel, ESLint, and other amazing projects, but provides a cohesive curated experience on top of them.
-
-* **No Configuration Required:** You don't need to configure anything. Reasonably good configuration of both development and production builds is handled for you so you can focus on writing code.
-
-* **No Lock-In:** You can โejectโ to a custom setup at any time. Run a single command, and all the configuration and build dependencies will be moved directly into your project, so you can pick up right where you left off.
-
-## Whatโs Included?
-
-Your environment will have everything you need to build a modern single-page React app:
-
-* React, JSX, ES6, and Flow syntax support.
-* Language extras beyond ES6 like the object spread operator.
-* Autoprefixed CSS, so you donโt need `-webkit` or other prefixes.
-* A fast interactive unit test runner with built-in support for coverage reporting.
-* A live development server that warns about common mistakes.
-* A build script to bundle JS, CSS, and images for production, with hashes and sourcemaps.
-* An offline-first [service worker](https://developers.google.com/web/fundamentals/getting-started/primers/service-workers) and a [web app manifest](https://developers.google.com/web/fundamentals/engage-and-retain/web-app-manifest/), meeting all the [Progressive Web App](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#making-a-progressive-web-app) criteria.
-* Hassle-free updates for the above tools with a single dependency.
-
-Check out [this guide](https://github.com/nitishdayal/cra_closer_look) for an overview of how these tools fit together.
-
-The tradeoff is that **these tools are preconfigured to work in a specific way**. If your project needs more customization, you can ["eject"](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#npm-run-eject) and customize it, but then you will need to maintain this configuration.
-
-## Popular Alternatives
-
-Create React App is a great fit for:
-
-* **Learning React** in a comfortable and feature-rich development environment.
-* **Starting new single-page React applications.**
-* **Creating examples** with React for your libraries and components.
-
-Hereโs a few common cases where you might want to try something else:
-
-* If you want to **try React** without hundreds of transitive build tool dependencies, consider [using a single HTML file or an online sandbox instead](https://reactjs.org/docs/try-react.html).
+Add a `.env.` file with the desired features.
-* If you need to **integrate React code with a server-side template framework** like Rails or Django, or if youโre **not building a single-page app**, consider using [nwb](https://github.com/insin/nwb) or [Neutrino](https://neutrino.js.org/) which are more flexible.
+### ๐ Configuration options
-* If you need to **publish a React component**, [nwb](https://github.com/insin/nwb) can [also do this](https://github.com/insin/nwb#react-components-and-libraries), as well as [Neutrino's react-components preset](https://neutrino.js.org/packages/react-components/).
+#### 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 name
-* If you want to do **server rendering** with React and Node.js, check out [Next.js](https://github.com/zeit/next.js/) or [Razzle](https://github.com/jaredpalmer/razzle). Create React App is agnostic of the backend, and just produces static HTML/JS/CSS bundles.
+Note: to use modules the file must be named in the following format: ```$name.module.$preprocessorName```.
-* If your website is **mostly static** (for example, a portfolio or a blog), consider using [Gatsby](https://www.gatsbyjs.org/) instead. Unlike Create React App, it pre-renders the website into HTML at the build time.
+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.
-* If you want to use **TypeScript**, consider using [create-react-app-typescript](https://github.com/wmonk/create-react-app-typescript).
+#### Babel
+- ```REACT_APP_BABEL_STAGE_0=true``` - enable stage-0 Babel preset
+- ```REACT_APP_DECORATORS=true``` - enable decorators support
-* Finally, if you need **more customization**, check out [Neutrino](https://neutrino.js.org/) and its [React preset](https://neutrino.js.org/packages/react/).
+#### 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)
-All of the above tools can work with little to no configuration.
+### ๐ค Why?
+The ```create-react-app``` app doesn't allow user configuration and modifications for few reasons:
-If you prefer configuring the build yourself, [follow this guide](https://reactjs.org/docs/add-react-to-an-existing-app.html).
+* 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.
-## Contributing
+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.
-We'd love to have your helping hand on `create-react-app`! See [CONTRIBUTING.md](CONTRIBUTING.md) for more information on what we're looking for and how to get started.
+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.
-## React Native
+### 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.
-Looking for something similar, but for React Native?
-Check out [Create React Native App](https://github.com/react-community/create-react-native-app/).
+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```
-## Acknowledgements
+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```.
-We are grateful to the authors of existing related projects for their ideas and collaboration:
+### Future plans
-* [@eanplatter](https://github.com/eanplatter)
-* [@insin](https://github.com/insin)
-* [@mxstbr](https://github.com/mxstbr)
+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.
diff --git a/examples/.env b/examples/.env
new file mode 100644
index 00000000000..0fba7f99c0d
--- /dev/null
+++ b/examples/.env
@@ -0,0 +1,31 @@
+# delete the environment strings as appropriate
+
+# enable SASS support
+REACT_APP_SASS=true
+
+# enable LESS support
+REACT_APP_LESS=true
+
+# enable Stylus support
+REACT_APP_STYLUS=true
+
+# enable CSS modules
+REACT_APP_CSS_MODULES=true
+
+# enable Sass modules
+REACT_APP_SASS_MODULES=true
+
+# enable Less modules
+REACT_APP_LESS_MODULES=true
+
+# enable Stylus modules
+REACT_APP_STYLUS_MODULES=true
+
+# enable stage-0 Babel preset
+REACT_APP_BABEL_STAGE_0=true
+
+# enable decorators support
+REACT_APP_DECORATORS=true
+
+# enable webpack dashboard access
+REACT_APP_WEBPACK_DASHBOARD=true
\ No newline at end of file
diff --git a/packages/create-react-app/createReactApp.js b/packages/create-react-app/createReactApp.js
index a2d9fdbd86b..0b60510cba6 100755
--- a/packages/create-react-app/createReactApp.js
+++ b/packages/create-react-app/createReactApp.js
@@ -481,7 +481,10 @@ function getPackageName(installPackage) {
);
} else if (installPackage.match(/^file:/)) {
const installPackagePath = installPackage.match(/^file:(.*)?$/)[1];
- const installPackageJson = require(path.join(installPackagePath, 'package.json'));
+ const installPackageJson = require(path.join(
+ installPackagePath,
+ 'package.json'
+ ));
return Promise.resolve(installPackageJson.name);
}
return Promise.resolve(installPackage);
diff --git a/packages/react-dev-utils/FileSizeReporter.js b/packages/react-dev-utils/FileSizeReporter.js
index 68aae411f12..968e57c3932 100644
--- a/packages/react-dev-utils/FileSizeReporter.js
+++ b/packages/react-dev-utils/FileSizeReporter.js
@@ -43,7 +43,7 @@ function printFileSizesAfterBuild(
name: path.basename(asset.name),
size: size,
sizeLabel:
- filesize(size) + (difference ? ' (' + difference + ')' : '')
+ filesize(size) + (difference ? ' (' + difference + ')' : ''),
};
})
)
diff --git a/packages/react-dev-utils/WebpackDevServerUtils.js b/packages/react-dev-utils/WebpackDevServerUtils.js
index 4add9f9c1bc..1208d7fc776 100644
--- a/packages/react-dev-utils/WebpackDevServerUtils.js
+++ b/packages/react-dev-utils/WebpackDevServerUtils.js
@@ -318,7 +318,7 @@ function prepareProxy(proxy, appPublicFolder) {
// However we also want to respect `proxy` for API calls.
// So if `proxy` is specified as a string, we need to decide which fallback to use.
// We use a heuristic: We want to proxy all the requests that are not meant
- // for static assets and as all the requests for static assets will be using
+ // for static assets and as all the requests for static assets will be using
// `GET` method, we can proxy all non-`GET` requests.
// For `GET` requests, if request `accept`s text/html, we pick /index.html.
// Modern browsers include text/html into `accept` header when navigating.
diff --git a/packages/react-dev-utils/clearConsole.js b/packages/react-dev-utils/clearConsole.js
index cb02af89237..2099a57ec35 100644
--- a/packages/react-dev-utils/clearConsole.js
+++ b/packages/react-dev-utils/clearConsole.js
@@ -8,7 +8,9 @@
'use strict';
function clearConsole() {
- process.stdout.write(process.platform === 'win32' ? '\x1B[2J\x1B[0f' : '\x1B[2J\x1B[3J\x1B[H');
+ process.stdout.write(
+ process.platform === 'win32' ? '\x1B[2J\x1B[0f' : '\x1B[2J\x1B[3J\x1B[H'
+ );
}
module.exports = clearConsole;
diff --git a/packages/react-dev-utils/getProcessForPort.js b/packages/react-dev-utils/getProcessForPort.js
index f9eda7752b4..8df45464977 100644
--- a/packages/react-dev-utils/getProcessForPort.js
+++ b/packages/react-dev-utils/getProcessForPort.js
@@ -58,7 +58,9 @@ function getProcessCommand(processId, processDirectory) {
function getDirectoryOfProcessById(processId) {
return execSync(
- 'lsof -p ' + processId + ' | awk \'$4=="cwd" {for (i=9; i<=NF; i++) printf "%s ", $i}\'',
+ 'lsof -p ' +
+ processId +
+ ' | awk \'$4=="cwd" {for (i=9; i<=NF; i++) printf "%s ", $i}\'',
execOptions
).trim();
}
diff --git a/packages/react-dev-utils/launchEditor.js b/packages/react-dev-utils/launchEditor.js
index cf190b08619..ddddb7930a7 100644
--- a/packages/react-dev-utils/launchEditor.js
+++ b/packages/react-dev-utils/launchEditor.js
@@ -56,8 +56,7 @@ const COMMON_EDITORS_OSX = {
'/Applications/RubyMine.app/Contents/MacOS/rubymine',
'/Applications/WebStorm.app/Contents/MacOS/webstorm':
'/Applications/WebStorm.app/Contents/MacOS/webstorm',
- '/Applications/MacVim.app/Contents/MacOS/MacVim':
- 'mvim',
+ '/Applications/MacVim.app/Contents/MacOS/MacVim': 'mvim',
};
const COMMON_EDITORS_LINUX = {
diff --git a/packages/react-scripts/README.md b/packages/react-scripts/README.md
index 8004b887004..44f88b61350 100644
--- a/packages/react-scripts/README.md
+++ b/packages/react-scripts/README.md
@@ -1,7 +1,72 @@
-# react-scripts
+# โข custom-react-scripts โข
+Latest version of original react-scripts: **1.1.14**
-This package includes scripts and configuration used by [Create React App](https://github.com/facebookincubator/create-react-app).
-Please refer to its documentation:
+### โ ๏ธ 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.
-* [Getting Started](https://github.com/facebookincubator/create-react-app/blob/master/README.md#getting-started) โ How to create a new app.
-* [User Guide](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md) โ How to develop apps bootstrapped with Create React App.
+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.
+
+### ๐ 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``` - enable CSS modules
+- ```REACT_APP_SASS_MODULES``` - enable Sass modules
+- ```REACT_APP_LESS_MODULES``` - enable Less modules
+- ```REACT_APP_STYLUS_MODULES``` - enable Stylus modules
+- ```REACT_APP_CSS_MODULE_CLASSNAME_TEMPLATE='module-[sha512:hash:base32]-[name]-[local]'``` - add custom CSS Module hash ident name
+
+Note: 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.
\ No newline at end of file
diff --git a/packages/react-scripts/bin/CUSTOM_README.md b/packages/react-scripts/bin/CUSTOM_README.md
new file mode 100644
index 00000000000..1776dce86cf
--- /dev/null
+++ b/packages/react-scripts/bin/CUSTOM_README.md
@@ -0,0 +1,65 @@
+# โข custom-react-scripts โข
+Latest version of original react-scripts: **0.8.4**
+
+### โ ๏ธ 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
+
+**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 SASS, LESS, and CSS modules support by default, but you can remove them at any time by removing the options from the ```.env``` file.
+
+### ๐ 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``` - enable CSS modules
+
+#### Babel
+- ```REACT_APP_BABEL_STAGE_0=true``` - enable stage-0 Babel preset
+- ```REACT_APP_DECORATORS=true``` - enable decorators support
+
+> โ ๏ธ Please note that the Babel features are highly experimental (especially stage-0) and still not a part of the ES specification.
+> Use them at your own risk of breaking backwards compatibility if they don't make the final version of the spec.
+
+#### Others
+- ```PORT=3015``` - change default port (supported in CRA by default)
+- ```OPEN_BROWSER=false``` - don't open browser after running webpack server
+
+### ๐ค 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.
diff --git a/packages/react-scripts/config/custom-react-scripts/config.js b/packages/react-scripts/config/custom-react-scripts/config.js
new file mode 100644
index 00000000000..25819dad1bc
--- /dev/null
+++ b/packages/react-scripts/config/custom-react-scripts/config.js
@@ -0,0 +1,24 @@
+const mapObject = require('./utils/map-object');
+
+const customizers = {
+ babelPlugins: require('./customizers/babel-plugins'),
+ babelPresets: require('./customizers/babel-presets'),
+ webpackLoaders: require('./customizers/webpack-loaders'),
+ webpackPlugins: require('./customizers/webpack-plugins'),
+};
+
+module.exports = getCustomConfig = (isDev = true) => {
+ var env = env || {};
+ const result = mapObject(customizers, group => {
+ return mapObject(
+ group,
+ (customizer, key) => {
+ const envValue = process.env['REACT_APP_' + key];
+ const activeEnvValue = env && envValue && envValue !== 'false';
+ return (activeEnvValue || customizer.default) && customizer.get(isDev);
+ },
+ true
+ );
+ });
+ return result;
+};
diff --git a/packages/react-scripts/config/custom-react-scripts/customizers/babel-plugins.js b/packages/react-scripts/config/custom-react-scripts/customizers/babel-plugins.js
new file mode 100644
index 00000000000..8650ecaee71
--- /dev/null
+++ b/packages/react-scripts/config/custom-react-scripts/customizers/babel-plugins.js
@@ -0,0 +1,5 @@
+module.exports = {
+ DECORATORS: {
+ get: () => require.resolve('babel-plugin-transform-decorators-legacy'),
+ },
+};
diff --git a/packages/react-scripts/config/custom-react-scripts/customizers/babel-presets.js b/packages/react-scripts/config/custom-react-scripts/customizers/babel-presets.js
new file mode 100644
index 00000000000..1060a35c5b6
--- /dev/null
+++ b/packages/react-scripts/config/custom-react-scripts/customizers/babel-presets.js
@@ -0,0 +1,5 @@
+module.exports = {
+ BABEL_STAGE_0: {
+ get: () => require.resolve('babel-preset-stage-0'),
+ },
+};
diff --git a/packages/react-scripts/config/custom-react-scripts/customizers/webpack-loaders.js b/packages/react-scripts/config/custom-react-scripts/customizers/webpack-loaders.js
new file mode 100644
index 00000000000..51094229fcd
--- /dev/null
+++ b/packages/react-scripts/config/custom-react-scripts/customizers/webpack-loaders.js
@@ -0,0 +1,43 @@
+const styleLoader = require('../webpack-config/style-loader');
+const sassLoader = require.resolve('sass-loader');
+const lessLoader = require.resolve('less-loader');
+const stylusLoader = require.resolve('stylus-loader');
+
+module.exports = {
+ CSS: {
+ default: true,
+ get: styleLoader(undefined, /\.css$/, /\.module\.css$/),
+ },
+ SASS: {
+ get: styleLoader(
+ sassLoader,
+ /\.s[ac]ss$/,
+ /\.module\.s[ac]ss$/,
+ false,
+ { includePaths: ['./node_modules', './src'] }
+ ),
+ },
+ LESS: {
+ get: styleLoader(lessLoader, /\.less$/, /\.module\.less$/),
+ },
+ STYLUS: {
+ get: styleLoader(stylusLoader, /\.styl/, /\.module\.styl/),
+ },
+ STYLUS_MODULES: {
+ get: styleLoader(stylusLoader, /\.module\.styl/, undefined, true),
+ },
+ LESS_MODULES: {
+ get: styleLoader(lessLoader, /\.module\.less$/, undefined, true),
+ },
+ SASS_MODULES: {
+ get: styleLoader(
+ sassLoader,
+ /\.module\.s[ac]ss$/,
+ undefined,
+ true,
+ { includePaths: ['./node_modules', './src'], }),
+ },
+ CSS_MODULES: {
+ get: styleLoader(undefined, /\.module\.css$/, undefined, true),
+ },
+};
diff --git a/packages/react-scripts/config/custom-react-scripts/customizers/webpack-plugins.js b/packages/react-scripts/config/custom-react-scripts/customizers/webpack-plugins.js
new file mode 100644
index 00000000000..58f9f6e90e6
--- /dev/null
+++ b/packages/react-scripts/config/custom-react-scripts/customizers/webpack-plugins.js
@@ -0,0 +1,7 @@
+const DashboardPlugin = require('webpack-dashboard/plugin');
+
+module.exports = {
+ WEBPACK_DASHBOARD: {
+ get: () => new DashboardPlugin(),
+ },
+};
diff --git a/packages/react-scripts/config/custom-react-scripts/options/extract-text-plugin-options.js b/packages/react-scripts/config/custom-react-scripts/options/extract-text-plugin-options.js
new file mode 100644
index 00000000000..c64d52dc3c9
--- /dev/null
+++ b/packages/react-scripts/config/custom-react-scripts/options/extract-text-plugin-options.js
@@ -0,0 +1,10 @@
+const paths = require('../../paths');
+
+const publicPath = paths.servedPath;
+const cssFilename = 'static/css/[name].[contenthash:8].css';
+const shouldUseRelativeAssetPaths = publicPath === './';
+
+module.exports = shouldUseRelativeAssetPaths
+ ? // Making sure that the publicPath goes back to to build folder.
+ { publicPath: Array(cssFilename.split('/').length).join('../') }
+ : {};
diff --git a/packages/react-scripts/config/custom-react-scripts/options/postcss-options.js b/packages/react-scripts/config/custom-react-scripts/options/postcss-options.js
new file mode 100644
index 00000000000..07c1a1278e1
--- /dev/null
+++ b/packages/react-scripts/config/custom-react-scripts/options/postcss-options.js
@@ -0,0 +1,12 @@
+const autoprefixer = require('autoprefixer');
+
+module.exports = {
+ ident: 'postcss',
+ plugins: () => [
+ require('postcss-flexbugs-fixes'),
+ autoprefixer({
+ browsers: ['>1%', 'last 4 versions', 'Firefox ESR', 'not ie < 9'],
+ flexbox: 'no-2009',
+ }),
+ ],
+};
diff --git a/packages/react-scripts/config/custom-react-scripts/utils/map-object.js b/packages/react-scripts/config/custom-react-scripts/utils/map-object.js
new file mode 100644
index 00000000000..c60b072a031
--- /dev/null
+++ b/packages/react-scripts/config/custom-react-scripts/utils/map-object.js
@@ -0,0 +1,13 @@
+module.exports = function mapObject(obj, fn, toArray) {
+ return Object.keys(obj).reduce(function(final, key) {
+ var result = fn(obj[key], key);
+ if (!result) {
+ return final;
+ }
+ if (toArray) {
+ final.push(result);
+ }
+ final[key] = result;
+ return final;
+ }, toArray ? [] : {});
+};
diff --git a/packages/react-scripts/config/custom-react-scripts/webpack-config/style-loader.js b/packages/react-scripts/config/custom-react-scripts/webpack-config/style-loader.js
new file mode 100644
index 00000000000..498aa00a031
--- /dev/null
+++ b/packages/react-scripts/config/custom-react-scripts/webpack-config/style-loader.js
@@ -0,0 +1,74 @@
+const postCssOptions = require('../options/postcss-options');
+const extractTextPluginOptions = require('../options/extract-text-plugin-options');
+const ExtractTextPlugin = require('extract-text-webpack-plugin');
+const shouldUseSourceMap = process.env.GENERATE_SOURCEMAP !== 'false';
+const localIdentName =
+ process.env.REACT_APP_CSS_MODULE_CLASSNAME_TEMPLATE ||
+ '[sha512:hash:base32]-[name]-[local]';
+
+module.exports = (loader, test, exclude, modules, options) => isDev => {
+ let loaders = isDev
+ ? [
+ {
+ loader: require.resolve('style-loader'),
+ },
+ ]
+ : [];
+
+ loaders = loaders.concat([
+ {
+ loader: require.resolve('css-loader'),
+ options: Object.assign(
+ { minimize: !isDev, sourceMap: shouldUseSourceMap },
+ { importLoaders: 1 },
+ modules === true
+ ? {
+ localIdentName: localIdentName,
+ modules: true,
+ }
+ : {}
+ ),
+ },
+ {
+ loader: require.resolve('postcss-loader'),
+ options: Object.assign(
+ {},
+ { sourceMap: shouldUseSourceMap },
+ postCssOptions
+ ),
+ },
+ ]);
+
+ if (loader) {
+ loaders.push({
+ loader,
+ options: Object.assign(
+ {},
+ { sourceMap: shouldUseSourceMap },
+ options
+ ),
+ });
+ }
+
+ if (isDev) {
+ return {
+ test,
+ exclude,
+ use: loaders,
+ };
+ }
+
+ return {
+ test,
+ exclude,
+ loader: ExtractTextPlugin.extract(
+ Object.assign(
+ {
+ fallback: require.resolve('style-loader'),
+ use: loaders,
+ },
+ extractTextPluginOptions
+ )
+ ),
+ };
+};
diff --git a/packages/react-scripts/config/jest/babelTransform.js b/packages/react-scripts/config/jest/babelTransform.js
index 02742e90c6c..0f7111920b6 100644
--- a/packages/react-scripts/config/jest/babelTransform.js
+++ b/packages/react-scripts/config/jest/babelTransform.js
@@ -8,8 +8,15 @@
'use strict';
const babelJest = require('babel-jest');
+const getCustomConfig = require('../custom-react-scripts/config');
+
+//Get custom configuration for injecting plugins, presets and loaders
+const customConfig = getCustomConfig(true);
module.exports = babelJest.createTransformer({
- presets: [require.resolve('babel-preset-react-app')],
+ presets: [require.resolve('babel-preset-react-app')].concat(
+ customConfig.babelPresets
+ ),
babelrc: false,
+ plugins: customConfig.babelPlugins,
});
diff --git a/packages/react-scripts/config/webpack.config.dev.js b/packages/react-scripts/config/webpack.config.dev.js
index 9f3131b0660..e6bc332a45b 100644
--- a/packages/react-scripts/config/webpack.config.dev.js
+++ b/packages/react-scripts/config/webpack.config.dev.js
@@ -8,7 +8,6 @@
// @remove-on-eject-end
'use strict';
-const autoprefixer = require('autoprefixer');
const path = require('path');
const webpack = require('webpack');
const HtmlWebpackPlugin = require('html-webpack-plugin');
@@ -19,6 +18,7 @@ const eslintFormatter = require('react-dev-utils/eslintFormatter');
const ModuleScopePlugin = require('react-dev-utils/ModuleScopePlugin');
const getClientEnvironment = require('./env');
const paths = require('./paths');
+const getCustomConfig = require('./custom-react-scripts/config');
// Webpack uses `publicPath` to determine where the app is being served from.
// In development, we always serve from the root. This makes config easier.
@@ -29,6 +29,8 @@ const publicPath = '/';
const publicUrl = '';
// Get environment variables to inject into our app.
const env = getClientEnvironment(publicUrl);
+//Get custom configuration for injecting plugins, presets and loaders
+const customConfig = getCustomConfig(true);
// This is the development configuration.
// It is focused on developer experience and fast rebuilds.
@@ -166,53 +168,18 @@ module.exports = {
include: paths.appSrc,
loader: require.resolve('babel-loader'),
options: {
- // @remove-on-eject-begin
babelrc: false,
- presets: [require.resolve('babel-preset-react-app')],
- // @remove-on-eject-end
+ presets: [require.resolve('babel-preset-react-app')].concat(
+ customConfig.babelPresets
+ ),
+ plugins: customConfig.babelPlugins,
// This is a feature of `babel-loader` for webpack (not Babel itself).
// It enables caching results in ./node_modules/.cache/babel-loader/
// directory for faster rebuilds.
cacheDirectory: true,
},
},
- // "postcss" loader applies autoprefixer to our CSS.
- // "css" loader resolves paths in CSS and adds assets as dependencies.
- // "style" loader turns CSS into JS modules that inject