Last active
January 13, 2019 16:46
-
-
Save imekachi/4edd1d3637bdb02f26c5dc4c371722af to your computer and use it in GitHub Desktop.
Unlock decorator syntax in create-react-app for MobX without ejecting using react-app-rewired.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* React-app-rewired, tweaking configs without ejecting create-react-app project | |
* | |
* 1. yarn add react-app-rewired babel-plugin-transform-decorators-legacy | |
* 2. copy this file to root (same as node_modules) and name it as 'config-overrides.js' | |
* 3. you can add more plugins if want, if not, skip to (4.) | |
* 4. edit package.json script to use 'react-app-rewired' instead of 'react-scripts' | |
* | |
* "scripts": { | |
* "start": "react-app-rewired start", | |
* "build": "react-app-rewired build", | |
* "test": "react-app-rewired test --env=jsdom", | |
* ... | |
* } | |
* | |
* 5. DONE! | |
* | |
* src: | |
* https://github.com/timarney/react-app-rewired#how-to-rewire-your-create-react-app-project | |
* https://medium.com/@timarney/but-i-dont-wanna-eject-3e3da5826e39 | |
*/ | |
const { injectBabelPlugin } = require('react-app-rewired') | |
module.exports = function override(config) { | |
// add your plugins or write your config here | |
const myPlugins = ['transform-decorators-legacy'] | |
return injectBabelPlugin(myPlugins, config) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks, you can find updated instructions for react-app-rewired 2.0.1 and later here: https://gist.github.com/Nomeyho/8eb0fc9aa068a14ef87cc0da94b6103c