Some time ago I made a vite/rollup plugin, to remove "data-testid" (or whatever you specify) from react source code for production builds Previous art was using babel (slow). npm: https://www.npmjs.com/package/rollup-plugin-jsx-remove-attributes git: https://github.com/jacobbogers/rollup-plugin-jsx-remove-attributes#readme