Skip to content

Instantly share code, notes, and snippets.

@devishot
Last active November 25, 2018 18:21
Show Gist options
  • Save devishot/cc45070359b304a7b22ecef247f63adb to your computer and use it in GitHub Desktop.
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
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