Created by: jsdevel
- This will allow for optional babel dependencies to be added without ejecting cra.
- CRA_BABEL_PRESET_FILE=relative/path/to/babel/preset can be added to package.json.
I verified this locally by copying index.js
to node_modules/babel-preset-react-app/index.js
within one of my projects. Here is the package.json for my project:
{
"name": "my-app",
"version": "0.1.0",
"private": true,
"dependencies": {
"babel-plugin-relay": "^1.1.0",
"react": "^15.6.1",
"react-dom": "^15.6.1",
"react-router-dom": "^4.1.1",
"react-scripts": "1.0.10",
"shared-git-hooks": "^1.2.1"
},
"scripts": {
"start": "CRA_BABEL_PRESET_FILE=.babel-preset-react-app react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject"
},
"homepage": "."
}
I'm doing this because I want to use relay modern in my app. My .babel-preset-react-app.js
file is exactly what @maletor had in PR https://github.com/facebookincubator/create-react-app/pull/2343
cc @gaearon Is this an acceptable approach per your comment https://github.com/facebookincubator/create-react-app/pull/2343#issuecomment-311409607 ?
Also relates to #2001 (closed)