Vite plugin to remove specified attributes (e.g., data-testid, data-cy) from React components during production builds. Current version 1.0.3 is marked as not fully tested. It filters files based on include/exclude patterns and requires Vite >=2.4.4. Unlike similar tools (e.g., babel-plugin-react-remove-properties), it integrates directly with Vite's build pipeline without additional Babel configuration.
npm install vite-plugin-react-remove-attributesVerified import paths — ran on the pinned version, not inferred.
Shows how to configure the plugin to remove 'data-testid' and 'data-cy' attributes from React components in a Vite project.
Test thoroughly in your build pipeline before using in production.
Use the 'include' and 'exclude' options to scope the plugin to your React components. Default include covers many file types.
Consider pinning version or waiting for stable releases.
Use: import VitePluginReactRemoveAttributes from 'vite-plugin-react-remove-attributes'
Run: npm install -D vite-plugin-react-remove-attributes
Ensure VitePluginReactRemoveAttributes is added to plugins array with attributes specified. Example: VitePluginReactRemoveAttributes({ attributes: ['data-testid'] })