{"id":20778028,"url":"https://github.com/mustafadalga/react-remove-attr","last_synced_at":"2026-04-09T19:55:00.382Z","repository":{"id":168021906,"uuid":"643657751","full_name":"mustafadalga/react-remove-attr","owner":"mustafadalga","description":"A Vite plugin designed specifically for React.js projects that allows the removal of specified attributes in production builds. Useful for excluding attributes like 'data-testid' used in testing. Options include specific file extensions, attributes, ignored folders, and files.","archived":false,"fork":false,"pushed_at":"2023-05-30T07:42:13.000Z","size":31,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-19T07:17:20.712Z","etag":null,"topics":["build-tool","javascript","jsx","optimization","react","reactjs","remove-attr","remove-attribute","remove-attributes","testing-library","testing-library-react","testing-library-vue","tsx","typescript","vite","vite-plugin","vitest","web-developer","web-development"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/react-remove-attr","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mustafadalga.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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-05-21T21:07:11.000Z","updated_at":"2023-05-22T14:37:14.000Z","dependencies_parsed_at":null,"dependency_job_id":"1b295f13-1246-48fd-9a2a-467933941fa5","html_url":"https://github.com/mustafadalga/react-remove-attr","commit_stats":null,"previous_names":["mustafadalga/react-remove-attr"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mustafadalga%2Freact-remove-attr","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mustafadalga%2Freact-remove-attr/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mustafadalga%2Freact-remove-attr/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mustafadalga%2Freact-remove-attr/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mustafadalga","download_url":"https://codeload.github.com/mustafadalga/react-remove-attr/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243119664,"owners_count":20239320,"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":["build-tool","javascript","jsx","optimization","react","reactjs","remove-attr","remove-attribute","remove-attributes","testing-library","testing-library-react","testing-library-vue","tsx","typescript","vite","vite-plugin","vitest","web-developer","web-development"],"created_at":"2024-11-17T13:18:42.116Z","updated_at":"2025-12-30T19:34:40.391Z","avatar_url":"https://github.com/mustafadalga.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Vite Plugin - React.js Remove Attributes\n\nSimplify your production code and enhance performance with this unique Vite plugin designed specifically for React.js\nprojects. The plugin seamlessly removes specified attributes from your tsx/jsx HTML codes during production builds,\nensuring a clutter-free and optimized application.\n\nThrough its robust functionality, this Vite plugin elevates your production code to a new level of cleanliness and\nefficiency. It's a must-have tool for any developer seeking to streamline their React.js applications for production.\n\n\n\u003cp align=\"center\"\u003e\n\n[![version](https://img.shields.io/npm/v/react-remove-attr.svg)](https://www.npmjs.com/package/react-remove-attr)\n[![vite version](https://img.shields.io/badge/vite-4.3.2-brightgreen.svg)](https://www.npmjs.com/package/vite)\n\n\u003c/p\u003e\n\n## Table of Contents\n\n- [Highlighted Features](#highlighted-features)\n- [Installation](#installation)\n- [Usage](#usage)\n    - [Prerequisites](#prerequisites)\n    - [Examples](#examples)\n- [License](#license)\n\n## Highlighted Features\n\n1. **Selective Attribute Removal:** The plugin gives you the power to choose which attributes you want to remove in the\n   production build of your React.js project. This feature is particularly useful for eliminating attributes like '\n   data-testid', which are only necessary during testing.\n\n2. **File Extension Specificity:** Customize the plugin according to the specific needs of your project. You can define\n   which file extensions should be considered for attribute removal. Currently, the plugin supports tsx and jsx\n   extensions.\n\n3. **Granular Exclusions:** Have some folders or files you want to exclude from the plugin's operation? No problem. This\n   plugin allows for configurable exemptions, meaning you can specify certain files or folders to be ignored during the\n   attribute removal process.\n\n4. **Clean Production Code:** By strategically removing unnecessary attributes, this plugin ensures your production code\n   is cleaner, leaner, and better performing. Say goodbye to bloated code and hello to optimized application\n   performance.\n\n## Installation\n\nYou can install this plugin through npm:\n\n```sh\nnpm install --save-dev react-remove-attr\n```\n\n## Usage\n\n### Prerequisites\n\nTo use this plugin, you need to have a Vite project set up. Import and use the plugin in your vite.config.js or\nvite.config.ts file.\n\n```typescript\nimport { defineConfig } from 'vite'\nimport react from '@vitejs/plugin-react'\nimport removeAttr from \"react-remove-attr\"\n\nexport default defineConfig({\n    plugins: [\n        removeAttr({\n            extensions: [],\n            attributes: []\n        }),\n        react(),\n    ],\n})\n```\n\n\u003cbr /\u003e \n\n## Examples\n\n#### Example 1: Removing 'data-testid', 'data-timestamp' and 'ignored-element' attributes from '.tsx' and \".jsx\" files\n\nThis configuration will remove 'data-testid', 'data-timestamp' and 'ignored-element' attributes from all '.tsx' and \".jsx\"\nfiles in the production build.\n\n```typescript\nexport default defineConfig({\n    plugins: [\n        removeAttr({\n            extensions: [ \"jsx\", \"tsx\" ],\n            attributes: [ 'data-testid', \"data-timestamp\", \"ignored-element\" ]\n        }),\n        react()\n    ]\n})\n```\n\n\u003cbr /\u003e \n\n#### Example 2: Ignoring specific folders and files\n\nThis configuration will remove 'data-testid' attributes from '.tsx' files, with the\nexception of those in the 'src/tests' and 'src/utilities' folders, as well as the 'src/Home.tsx', '\nsrc/components/Modal.tsx', and 'src/layouts/LayoutAuth.tsx' files.\n\n```typescript\nexport default defineConfig({\n    plugins: [\n        removeAttr({\n            extensions: [ \"tsx\" ],\n            attributes: [ 'data-testid'],\n            ignoreFolders: [ 'src/tests', \"src/utilities\" ],\n            ignoreFiles: [ 'src/Home.tsx', 'src/components/Modal.tsx', \"src/layouts/LayoutAuth.tsx\" ]\n        }),\n        react()\n    ]\n})\n```\n\n\u003cbr /\u003e \n\n## License\n\n[![License](https://img.shields.io/badge/LICENSE-GPL--3.0-orange)](https://github.com/mustafadalga/react-remove-attr/blob/main/LICENSE)\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmustafadalga%2Freact-remove-attr","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmustafadalga%2Freact-remove-attr","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmustafadalga%2Freact-remove-attr/lists"}