{"id":13604896,"url":"https://github.com/jacobbogers/rollup-plugin-jsx-remove-attributes","last_synced_at":"2026-03-15T03:02:34.206Z","repository":{"id":143462751,"uuid":"615684254","full_name":"jacobbogers/rollup-plugin-jsx-remove-attributes","owner":"jacobbogers","description":"rollup \u0026 vite plugin to remove jsx attributes","archived":false,"fork":false,"pushed_at":"2024-04-05T19:53:59.000Z","size":59,"stargazers_count":2,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-04-14T07:19:31.009Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jacobbogers.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-03-18T11:29:21.000Z","updated_at":"2024-05-13T17:23:14.069Z","dependencies_parsed_at":"2024-05-13T17:33:21.782Z","dependency_job_id":null,"html_url":"https://github.com/jacobbogers/rollup-plugin-jsx-remove-attributes","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jacobbogers%2Frollup-plugin-jsx-remove-attributes","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jacobbogers%2Frollup-plugin-jsx-remove-attributes/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jacobbogers%2Frollup-plugin-jsx-remove-attributes/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jacobbogers%2Frollup-plugin-jsx-remove-attributes/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jacobbogers","download_url":"https://codeload.github.com/jacobbogers/rollup-plugin-jsx-remove-attributes/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248262153,"owners_count":21074255,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-01T19:00:52.470Z","updated_at":"2026-03-15T03:02:34.198Z","avatar_url":"https://github.com/jacobbogers.png","language":"TypeScript","funding_links":[],"categories":["Plugins","Get Started"],"sub_categories":["Output","Templates"],"readme":"\n# rollup(\u0026 vite)-plugin-jsx-remove-attributes\n\nrollup \u0026amp; vite plugin to remove jsx attributes\n\nThis plugin can be used in vite or rollup.\n\nThe initial motivation was to remove `data-testid` attributes from jsx (react, etc) components.\n\nIt can be generally used to remove any number of attributes.\n\nThe plugin only runs when `NODE_ENV` matches the values of the `environments` option (default is `['production']`).\n\n## Table of contents\n\u003c!-- vscode-markdown-toc --\u003e\n1. [Installation](#Installation)\n2. [Usage with Vite](#UsagewithVite)\n3. [Usage with Rollup](#UsagewithRollup)\n4. [Options Object](#OptionsObject)\n5. [Usage with Preact](#UsagewithPreact)\n6. [Usage with Babel](#UsagewithBabel)\n\n\u003c!-- vscode-markdown-toc-config\n\tnumbering=true\n\tautoSave=true\n\t/vscode-markdown-toc-config --\u003e\n\u003c!-- /vscode-markdown-toc --\u003e\n\n##  1. \u003ca name='Installation'\u003e\u003c/a\u003eInstallation\n\n```bash\n\nnpm i -D rollup-plugin-jsx-remove-attributes\n```\n\n##  2. \u003ca name='UsagewithVite'\u003e\u003c/a\u003eUsage with Vite\n\nExample:\n\n```typescript\nimport { defineConfig } from 'vite';\nimport react from '@vitejs/plugin-react';\n\nimport removeTestIdAttribute from 'rollup-plugin-jsx-remove-attributes';\n\nexport default defineConfig({\n    build: { sourcemap: true },\n    plugins: [\n        react(),\n        removeTestIdAttribute({\n            include: [/\\.[tj]sx$/], //default\n            exclude: ['**/node_modules/**'], // default\n            attributes: ['data-testid'], // default, array of attribute names to strip from jsx\n            environments: ['production', 'pre-prod', 'prod', 'q\u0026a'], // default = [\"production\"]\n            debug: false, // is the default, if \"true\" show more logging of the internal workings of this plugin, for troubleshooting configs\n            usage: 'vite' // Must specify for vite use, default usage is rollup\n        })\n        // other plugins\n    ]\n});\n```\n\n##  3. \u003ca name='UsagewithRollup'\u003e\u003c/a\u003eUsage with Rollup\n\nExample:\n\n```typescript\nimport { rollup } from 'rollup';\nimport removeTestIdAttribute from 'rollup-plugin-jsx-remove-attributes';\n\n// see below for details on these options\nconst inputOptions = {\n    ...\n    plugins:[\n      removeTestIdAttribute({\n            include: [/\\.[tj]sx$/], //default\n            exclude: ['**/node_modules/**'], // default\n            attributes: ['data-testid'],  // default, array of attribute names to strip from jsx\n            environments: ['production', 'pre-prod', 'prod', 'q\u0026a'], // default = [\"production\"]\n            debug: false, // is the default, if \"true\" show more logging of the internal workings of this plugin, for troubleshooting configs\n            usage: 'rollup'  // default,  when configuring for rollup \"usage\" can be omitted, shown for clarity only\n        }),\n    ]\n};\n\nconst outputOptions = {...};\n\nconst bundle = await rollup.build(inputOptions);\n\nawait rollup.write(outputOptions);\n```\n\n##  4. \u003ca name='OptionsObject'\u003e\u003c/a\u003eOptions Object\n\n-   `usage`: default `rollup`, possible values are `vite` or `rollup`,\n-   `include`: default`[/\\.[tj]sx$/]`, will allow anything that matches the array of glob/regexp pattern, default`[/\\.[tj]sx$/]`\n-   `exclude`: default `['**/node_modules/**']`, will exclude anything matching the array of glob/regexp patterns\n-   `attributes`: (optional default = [`data-testid`] ) array of jsx attributes to be stripped if found\n-   `environments`: array of strings representing values of NODE_ENV for wich this plugin will run.\n-   `debug`: default `false`, show more logging of internal workings of the plugin, default false\n\n\n##  5. \u003ca name='UsagewithPreact'\u003e\u003c/a\u003eUsage with Preact\n\nPreact is now supported since version 3.1.0\n\nPlease take care the insert this plugin before any minification/uglify plugin.\n\nFor example:\n\n```javascript\n// imports removed for brevity\n//\n// https://vitejs.dev/config/\nexport default defineConfig({\n    plugins: [\n        esbuild(),\n        jsxRemoveAttributes(), // \u003c-- this plugin\n        minify()\n    ],\n    //\n    // other config info removed for brevity\n});\n```\n\nFor more information see [issue][7]\n\n\n##  6. \u003ca name='UsagewithBabel'\u003e\u003c/a\u003eUsage with Babel\n\nSince version 3.1.2 supporting runtime injections of @babel/plugin-transform-react-jsx. ([this PR][pr-10]).\n\n[pr-10]: https://github.com/jacobbogers/rollup-plugin-jsx-remove-attributes/pull/10\n[7]: https://github.com/jacobbogers/rollup-plugin-jsx-remove-attributes/issues/7\n\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjacobbogers%2Frollup-plugin-jsx-remove-attributes","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjacobbogers%2Frollup-plugin-jsx-remove-attributes","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjacobbogers%2Frollup-plugin-jsx-remove-attributes/lists"}