Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
hacking CRA to work with babel-plugin-relay
"scripts": {
"build": "node ./setup && react-scripts build"
const fs = require('fs');
const path = require('path');
const file = path.resolve('./node_modules/babel-preset-react-app/index.js');
var text = fs.readFileSync(file, 'utf8');
if (!text.includes('babel-plugin-relay')) {
if (text.includes('const plugins = [')) {
text = text.replace(
'const plugins = [',
"const plugins = [\n require.resolve('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
You can’t perform that action at this time.