https://github.com/timarney/react-app-rewired
// config-overrides.js
const babelLoader = function(conf) {
if (!conf.loader) return false;
return conf.loader.indexOf('babel-loader') > -1;
};
// Emotion
function rewireEmotion(config, env) {
const babelrc = config.module.rules.find(babelLoader).options;
babelrc.plugins = ['emotion/babel'].concat(babelrc.plugins || []);
return config;
}
function rewireStyledJSX(config, env) {
const babelrc = config.module.rules.find(babelLoader).options;
babelrc.plugins = ['styled-jsx/babel'].concat(babelrc.plugins || []);
return config;
}
module.exports = function override(config, env) {
config = rewireEmotion(config, env);
config = rewireStyledJSX(config, env);
return config;
};
Just found out about this: https://github.com/timarney/react-app-rewired.
It might make this 10x easier than doing these manual compiles above.