{"id":29731108,"url":"https://github.com/ifaxity/vite-plugin-istanbul","last_synced_at":"2025-07-25T06:12:41.023Z","repository":{"id":38309880,"uuid":"286056954","full_name":"iFaxity/vite-plugin-istanbul","owner":"iFaxity","description":"A Vite plugin to instrument code for nyc/istanbul code coverage. In similar way as the Webpack Loader istanbul-instrumenter-loader. Only intended for use in development.","archived":false,"fork":false,"pushed_at":"2025-07-08T12:20:31.000Z","size":1486,"stargazers_count":103,"open_issues_count":10,"forks_count":21,"subscribers_count":2,"default_branch":"next","last_synced_at":"2025-07-08T12:58:10.467Z","etag":null,"topics":["coverage","cypress-plugin","istanbul","plugin","vite","vitejs"],"latest_commit_sha":null,"homepage":"","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/iFaxity.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","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,"zenodo":null}},"created_at":"2020-08-08T14:19:18.000Z","updated_at":"2025-07-08T12:20:53.000Z","dependencies_parsed_at":"2024-06-24T20:45:54.153Z","dependency_job_id":"9fe3733c-c127-4b0e-a3d7-2337752e9b2c","html_url":"https://github.com/iFaxity/vite-plugin-istanbul","commit_stats":{"total_commits":92,"total_committers":16,"mean_commits":5.75,"dds":0.5760869565217391,"last_synced_commit":"7607e7c47b41a07ff58a75e635d932a5c7927652"},"previous_names":[],"tags_count":47,"template":false,"template_full_name":null,"purl":"pkg:github/iFaxity/vite-plugin-istanbul","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iFaxity%2Fvite-plugin-istanbul","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iFaxity%2Fvite-plugin-istanbul/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iFaxity%2Fvite-plugin-istanbul/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iFaxity%2Fvite-plugin-istanbul/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/iFaxity","download_url":"https://codeload.github.com/iFaxity/vite-plugin-istanbul/tar.gz/refs/heads/next","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iFaxity%2Fvite-plugin-istanbul/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266964322,"owners_count":24013247,"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","status":"online","status_checked_at":"2025-07-25T02:00:09.625Z","response_time":70,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["coverage","cypress-plugin","istanbul","plugin","vite","vitejs"],"created_at":"2025-07-25T06:12:39.146Z","updated_at":"2025-07-25T06:12:41.013Z","avatar_url":"https://github.com/iFaxity.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"vite-plugin-istanbul\n==========================\n\n[![Codacy grade](https://img.shields.io/codacy/grade/a0c628b128c044269faefc1da74382f7?style=for-the-badge\u0026logo=codacy)](https://www.codacy.com/gh/iFaxity/vite-plugin-istanbul/dashboard)\n[![npm (scoped)](https://img.shields.io/npm/v/vite-plugin-istanbul?style=for-the-badge\u0026logo=npm)](https://npmjs.org/package/vite-plugin-istanbul)\n[![npm bundle size (scoped)](https://img.shields.io/bundlephobia/min/vite-plugin-istanbul?label=Bundle%20size\u0026style=for-the-badge)](https://npmjs.org/package/vite-plugin-istanbul)\n[![npm bundle size (scoped)](https://img.shields.io/bundlephobia/minzip/vite-plugin-istanbul?label=Bundle%20size%20%28gzip%29\u0026style=for-the-badge)](https://npmjs.org/package/vite-plugin-istanbul)\n\n\u003e This project is looking for new maintainers. See CONTRIBUTING.md\n\nA Vite plugin to instrument your code for nyc/istanbul code coverage. In similar way as the Webpack Loader `istanbul-instrumenter-loader`. Only intended for use in development while running tests.\n\nOnly versions targeting the latest stable Vite version is actively developed.\n\nInstallation\n--------------------------\n`npm i -D vite-plugin-istanbul`\n\nor if you use yarn\n\n`yarn add -D vite-plugin-istanbul`\n\nAPI\n--------------------------\n\n```js\nimport IstanbulPlugin from 'vite-plugin-istanbul';\n```\n\n### [IstanbulPlugin( [ opts ] )](#istanbul-plugin)\n\nCreates the vite plugin from a set of optional plugin options.\n\n**Returns:** Vite Plugin\n\n#### Parameters\n\n| Parameter              | Type               | Description                                                                                                                                                                                                                                                                                                           |\n| ---------------------- | ------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| `cwd`                  | `string`           | Optional string of the current working directory, used for the include/exclude patterns. Defaults to `process.cwd()`.                                                                                                                                                                                                 |\n| `include`              | `string\\|string[]` | Optional string or array of strings of glob patterns to include.                                                                                                                                                                                                                                                      |\n| `exclude`              | `string\\|string[]` | Optional string or array of strings of glob patterns to exclude.                                                                                                                                                                                                                                                      |\n| `extension`            | `string\\|string[]` | Optional string or array of strings of extensions to include (dot prefixed like .js or .ts). By default this is set to `['.js', '.cjs', '.mjs', '.ts', '.tsx', '.jsx', '.vue']`.                                                                                                                                      |\n| `requireEnv`           | `boolean`          | Optional boolean to require the environment variable (defaults to **VITE_COVERAGE**) to equal `true` in order to instrument the code. Otherwise it will instrument even if env variable is not set. However if `requireEnv` is not set the instrumentation will stop if the environment variable is equal to `false`. |\n| `cypress`              | `boolean`          | Optional boolean to change the environment variable to **CYPRESS_COVERAGE** instead of **VITE_COVERAGE**. For ease of use with `@cypress/code-coverage`.                                                                                                                                                              |\n| `checkProd`            | `boolean`          | Optional boolean to enforce the plugin to skip instrumentation for production environments. Looks at Vite's **isProduction** key from the `ResolvedConfig`.                                                                                                                                                           |\n| `forceBuildInstrument` | `boolean`          | Optional boolean to enforce the plugin to add instrumentation in build mode. Defaults to false.                                                                                                                                                                                                                       |\n| `nycrcPath`            | `string`           | Path to specific nyc config to use instead of automatically searching for a nycconfig. This parameter is just passed down to `@istanbuljs/load-nyc-config`.                                                                                                                                                           |\n| `generatorOpts`        | `GeneratorOptions` | A set of generator options that are passed down to the Babel transformer. See [here](https://babeljs.io/docs/babel-generator#options) for reference. Defaults to empty object.                                                                                                                                        |\n\nNotes\n--------------------------\n\nAs of v2.1.0 you can toggle the coverage off by setting the env variable `VITE_COVERAGE='false'`, by default it will always instrument the code. To require the explicit definition of the variable, set the option `requireEnv` to **true**.\n\nThis plugin also requires the Vite configuration [build.sourcemap](https://vitejs.dev/config/#build-sourcemap) to be set to either **true**, **'inline'**, **'hidden'**.\nBut the plugin will automatically default to **true** if it is missing in order to give accurate code coverage.\nThe plugin will notify when this happens in order for a developer to fix it. This notification will show even when the plugin is disabled by e.g `opts.requireEnv`, `VITE_COVERAGE=false`. This is due to a limitation of the API for this kind of feature.\n\nExamples\n--------------------------\n\nTo use this plugin define it using vite.config.js\n\n```js\n// vite.config.js\nimport istanbul from 'vite-plugin-istanbul';\n\nexport default {\n  open: true,\n  port: 3000,\n  plugins: [\n    istanbul({\n      include: 'src/*',\n      exclude: ['node_modules', 'test/'],\n      extension: ['.js', '.ts', '.vue'],\n      requireEnv: true,\n    }),\n  ],\n};\n```\n\nLooking for contributors and maintainers\n---------------------------------------------\n\nThis project is not under active development, although we will continue to provide support for current users, but you can change that by joining the team (see CONTRIBUTING.md)\n\nIf you use this project and would like to develop it further, please introduce yourself on the [Maintainers wanted](https://github.com/iFaxity/vite-plugin-istanbul/issues/341) ticket.\n\nLicense\n--------------------------\n\n[MIT](./LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fifaxity%2Fvite-plugin-istanbul","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fifaxity%2Fvite-plugin-istanbul","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fifaxity%2Fvite-plugin-istanbul/lists"}