Last active
November 25, 2018 18:21
-
-
Save devishot/cc45070359b304a7b22ecef247f63adb to your computer and use it in GitHub Desktop.
Fix for new version of "babel-preset-react-app": "^6.1.0". Original script was taken from https://hackernoon.com/using-create-react-app-with-relay-modern-989c078fa892
This file contains 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
const fs = require('fs'); | |
const path = require('path'); | |
const file = path.resolve('./node_modules/babel-preset-react-app/create.js'); | |
var text = fs.readFileSync(file, 'utf8'); | |
if (!text.includes('babel-plugin-relay')) { | |
if (text.includes("require('babel-plugin-macros'),")) { | |
text = text.replace( | |
"require('babel-plugin-macros'),", | |
"require('babel-plugin-macros'),\nrequire('babel-plugin-relay'),", | |
); | |
fs.writeFileSync(file, text, 'utf8'); | |
} else { | |
throw new Error(`Failed to inject babel-plugin-relay.`); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment