diff --git a/packages/react-scripts/scripts/eject.js b/packages/react-scripts/scripts/eject.js index b1c5e5420f4..9b008fb7e2b 100644 --- a/packages/react-scripts/scripts/eject.js +++ b/packages/react-scripts/scripts/eject.js @@ -130,7 +130,7 @@ prompt( ); // Add Babel config if there is no local babel config - if (isLocalBabelExists()) { + if (!isLocalBabelExists()) { console.log(' Adding ' + cyan('Babel') + ' preset'); appPackage.babel = babelConfig; } diff --git a/packages/react-scripts/template/.babelrc b/packages/react-scripts/template/.babelrc deleted file mode 100644 index c14b2828d16..00000000000 --- a/packages/react-scripts/template/.babelrc +++ /dev/null @@ -1,3 +0,0 @@ -{ - "presets": ["react-app"] -} diff --git a/packages/react-scripts/template/README.md b/packages/react-scripts/template/README.md index e55e6c9f4f8..533ef74994e 100644 --- a/packages/react-scripts/template/README.md +++ b/packages/react-scripts/template/README.md @@ -28,6 +28,7 @@ You can find the most recent version of this guide [here](https://github.com/fac - [Using Global Variables](#using-global-variables) - [Adding Bootstrap](#adding-bootstrap) - [Adding Flow](#adding-flow) +- [Adding Custom Babel Configuration](#adding-custom-babel-configuration) - [Adding Custom Environment Variables](#adding-custom-environment-variables) - [Can I Use Decorators?](#can-i-use-decorators) - [Integrating with a Node Backend](#integrating-with-a-node-backend) @@ -494,6 +495,18 @@ In the future we plan to integrate it into Create React App even more closely. To learn more about Flow, check out [its documentation](https://flowtype.org/). +## Adding Custom Babel Configuration + +You can override builtin babel presets and plugins [via .babelrc or package.json](https://babeljs.io/docs/usage/babelrc/). + +>Note: Don't forget to install babel-preset-react-app and include "react-app" preset into your .babelrc or package.json babel configuration section. + +```js +{ + "presets": ["react-app", "stage-0"] +} +``` + ## Adding Custom Environment Variables >Note: this feature is available with `react-scripts@0.2.3` and higher.