Skip to content

Instantly share code, notes, and snippets.

@simonghales
Created January 22, 2021 02:49
Show Gist options
  • Save simonghales/792922a2e32d2eeb06f6f1947bab1348 to your computer and use it in GitHub Desktop.
Save simonghales/792922a2e32d2eeb06f6f1947bab1348 to your computer and use it in GitHub Desktop.
addExternalBabelPlugin not working for customize-cra (react app rewired) alternative solution

this wasn't working:

const { override, addExternalBabelPlugin } = require('customize-cra');

module.exports = override(addExternalBabelPlugin('babel-plugin-react-engine'))

this instead worked:

const { override, getBabelLoader } = require('customize-cra');

const prependBabelPlugin = (plugin) => (config) => {
    getBabelLoader(config).options.plugins.unshift(plugin);
    return config;
};

module.exports = override(prependBabelPlugin('babel-plugin-react-engine'));

thanks to: arackaf/customize-cra#240

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment