5
votes

Is it possible to connect Create React App 2 with this plugin: https://www.npmjs.com/package/babel-plugin-jsx-remove-data-test-id without ejecting? I've created .bablerc file, but it doesn't work. I want to use custom attribute for bdd testing and remove this attribute on production.

Also, I don't want to create HOC to apply attribute - I have many components and wrap every component is very very difficult.

1

1 Answers

0
votes

You can use react-app-rewired https://www.npmjs.com/package/react-app-rewired and override the configs through the config-override.js file:

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

module.exports = override(
  ...addBabelPresets([
    '@babel/preset-env',
    {
      modules: false,
      useBuiltIns: false,
      debug: false,
    },
  ]),
  ...addBabelPlugins(
    'babel-plugin-styled-components',
    'babel-plugin-jsx-remove-data-test-id',
  ),
);