{"id":22805,"library":"vite-plugin-react-remove-attributes","title":"vite-plugin-react-remove-attributes","description":"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.","status":"active","version":"1.0.3","language":"javascript","source_language":"en","source_url":"https://github.com/l-mbert/vite-plugin-react-remove-attributes","tags":["javascript","vite","vite-plugin","react-remove-attributes","typescript"],"install":[{"cmd":"npm install vite-plugin-react-remove-attributes","lang":"bash","label":"npm"},{"cmd":"yarn add vite-plugin-react-remove-attributes","lang":"bash","label":"yarn"},{"cmd":"pnpm add vite-plugin-react-remove-attributes","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"peer dependency: requires Vite >=2.4.4","package":"vite","optional":false}],"imports":[{"note":"Package uses default export. Named import will not work.","wrong":"import { VitePluginReactRemoveAttributes } from 'vite-plugin-react-remove-attributes'","symbol":"VitePluginReactRemoveAttributes","correct":"import VitePluginReactRemoveAttributes from 'vite-plugin-react-remove-attributes'"},{"note":"CommonJS users must access .default due to ESM/CJS interop.","wrong":"const VitePluginReactRemoveAttributes = require('vite-plugin-react-remove-attributes')","symbol":"CommonJS require","correct":"const VitePluginReactRemoveAttributes = require('vite-plugin-react-remove-attributes').default"},{"note":"Type is exported for options if needed.","wrong":"","symbol":"TypeScript type","correct":"import type { VitePluginReactRemoveAttributesOptions } from 'vite-plugin-react-remove-attributes'"}],"quickstart":{"code":"import { defineConfig } from 'vite';\nimport VitePluginReactRemoveAttributes from 'vite-plugin-react-remove-attributes';\n\nexport default defineConfig({\n  plugins: [\n    VitePluginReactRemoveAttributes({\n      attributes: ['data-testid', 'data-cy'],\n    }),\n  ],\n});","lang":"typescript","description":"Shows how to configure the plugin to remove 'data-testid' and 'data-cy' attributes from React components in a Vite project."},"warnings":[{"fix":"Test thoroughly in your build pipeline before using in production.","message":"Package README states 'NOT ALL CASES TESTED YET, USE WITH CARE'. It may not work in all scenarios.","severity":"gotcha","affected_versions":">=0.0.1"},{"fix":"Use the 'include' and 'exclude' options to scope the plugin to your React components. Default include covers many file types.","message":"The plugin removes attributes from all files matching include/exclude patterns, which may include non-React files if not configured properly.","severity":"gotcha","affected_versions":">=0.0.1"},{"fix":"Consider pinning version or waiting for stable releases.","message":"No known deprecations yet, but version 1.0.3 is early and API may change.","severity":"deprecated","affected_versions":"1.0.3"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Use: import VitePluginReactRemoveAttributes from 'vite-plugin-react-remove-attributes'","cause":"Incorrect import: using named import instead of default import.","error":"TypeError: VitePluginReactRemoveAttributes is not a function"},{"fix":"Run: npm install -D vite-plugin-react-remove-attributes","cause":"Package not installed or incomplete installation.","error":"Error: Cannot find module 'vite-plugin-react-remove-attributes'"},{"fix":"Ensure VitePluginReactRemoveAttributes is added to plugins array with attributes specified. Example: VitePluginReactRemoveAttributes({ attributes: ['data-testid'] })","cause":"Plugin not added to Vite config or options misconfigured.","error":"The attribute 'data-testid' was not removed in production build"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}