Registry / testing / vite-plugin-react-remove-attributes

vite-plugin-react-remove-attributes

JSON →
library1.0.3jsnpmunverified

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-attributes
INSTALL
IMPORT
SIG · VITE-PLUGIN-REACT-
V
vite-plugin-react-remove-attributes
testingjavascriptv1.0.3
Install
—
Import
—
Disk
—
Pass rate
0/ 6
Env Coverage0 / 6
glibc
18–22
musl
18–22
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18–223 runs
build_error
glibc
node 18–223 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

VitePluginReactRemoveAttributes
✓ import VitePluginReactRemoveAttributes from 'vite-plugin-react-remove-attributes'
✗ import { VitePluginReactRemoveAttributes } from 'vite-plugin-react-remove-attributes'
Package uses default export. Named import will not work.
CommonJS require
✓ const VitePluginReactRemoveAttributes = require('vite-plugin-react-remove-attributes').default
✗ const VitePluginReactRemoveAttributes = require('vite-plugin-react-remove-attributes')
CommonJS users must access .default due to ESM/CJS interop.
TypeScript type
✓ import type { VitePluginReactRemoveAttributesOptions } from 'vite-plugin-react-remove-attributes'
Type is exported for options if needed.

Shows how to configure the plugin to remove 'data-testid' and 'data-cy' attributes from React components in a Vite project.

import { defineConfig } from 'vite'; import VitePluginReactRemoveAttributes from 'vite-plugin-react-remove-attributes'; export default defineConfig({ plugins: [ VitePluginReactRemoveAttributes({ attributes: ['data-testid', 'data-cy'], }), ], });
Debug
Known issues
gotchaPackage README states 'NOT ALL CASES TESTED YET, USE WITH CARE'. It may not work in all scenarios.
fix
Test thoroughly in your build pipeline before using in production.
affects: >=0.0.1
gotchaThe plugin removes attributes from all files matching include/exclude patterns, which may include non-React files if not configured properly.
fix
Use the 'include' and 'exclude' options to scope the plugin to your React components. Default include covers many file types.
affects: >=0.0.1
deprecatedNo known deprecations yet, but version 1.0.3 is early and API may change.
fix
Consider pinning version or waiting for stable releases.
affects: 1.0.3
Errors
Common errors & fixes
TypeError: VitePluginReactRemoveAttributes is not a function
Incorrect import: using named import instead of default import.
fix
Use: import VitePluginReactRemoveAttributes from 'vite-plugin-react-remove-attributes'
Error: Cannot find module 'vite-plugin-react-remove-attributes'
Package not installed or incomplete installation.
fix
Run: npm install -D vite-plugin-react-remove-attributes
The attribute 'data-testid' was not removed in production build
Plugin not added to Vite config or options misconfigured.
fix
Ensure VitePluginReactRemoveAttributes is added to plugins array with attributes specified. Example: VitePluginReactRemoveAttributes({ attributes: ['data-testid'] })
Upgrade
Version history
1.0.3latest on npm
Audit
Dependencies
viterequiredpeer dependency: requires Vite >=2.4.4
Agent activity
12 hits · last 30 days
node
12
Resources
vite-plugin-react-remove-attributes — npm install vite-plugin-react-remove-attributes · libregistry