{"id":22896,"library":"vite-plugin-tsconfig","title":"Vite Plugin Tsconfig","description":"Vite plugin to specify an alternate tsconfig filename, useful for monorepos and CI environments. Current stable version is 2.0.0, released with breaking changes migrating to buildStart/buildEnd hooks. Key differentiator: allows swapping tsconfig files per workspace package in monorepos, with backup/restore of the original tsconfig.json. Note that as of Vite 7.1.5, the native optimizeDeps.esbuildOptions.tsconfig option may suffice, but this plugin remains necessary for monorepos with externalized paths.","status":"active","version":"2.0.0","language":"javascript","source_language":"en","source_url":"https://github.com/alienfast/vite-plugin-tsconfig","tags":["javascript","vite-plugin","tsconfig","typescript"],"install":[{"cmd":"npm install vite-plugin-tsconfig","lang":"bash","label":"npm"},{"cmd":"yarn add vite-plugin-tsconfig","lang":"bash","label":"yarn"},{"cmd":"pnpm add vite-plugin-tsconfig","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Peer dependency - requires Vite >=3.1.6","package":"vite","optional":true}],"imports":[{"note":"Default export; ESM-only.","wrong":"const tsconfig = require('vite-plugin-tsconfig')","symbol":"tsconfig","correct":"import tsconfig from 'vite-plugin-tsconfig'"},{"note":"TypeScript types are shipped; use default import.","symbol":"tsconfig (with type import)","correct":"import tsconfig from 'vite-plugin-tsconfig'"},{"note":"Type-only export; import type is recommended.","wrong":"import { PluginOptions } from 'vite-plugin-tsconfig'","symbol":"PluginOptions","correct":"import type { PluginOptions } from 'vite-plugin-tsconfig'"}],"quickstart":{"code":"import { defineConfig } from 'vite';\nimport tsconfig from 'vite-plugin-tsconfig';\n\nexport default defineConfig({\n  plugins: [\n    tsconfig({\n      filename: 'tsconfig.build.json',\n      logLevel: 'info',\n      workspaces: ['packages/ui', 'packages/notifications'],\n    }),\n  ],\n});","lang":"typescript","description":"Configures Vite to use an alternate tsconfig file during build, with optional workspace packages for monorepos."},"warnings":[{"fix":"Update plugin configuration if relying on specific hook behavior; in most cases no code changes are needed.","message":"v2.0.0 migrated from configResolved/buildStart hooks to buildStart/buildEnd hooks, which may affect plugin ordering and lifecycle timing.","severity":"breaking","affected_versions":">=2.0.0"},{"fix":"Consider removing the plugin and using Vite's native esbuildOptions.tsconfig.","message":"Plugin may be unnecessary for typical use cases as of Vite 7.1.5, which supports optimizeDeps.esbuildOptions.tsconfig natively.","severity":"deprecated","affected_versions":">=2.0.0"},{"fix":"Ensure proper error handling or have version control to recover the original tsconfig.json.","message":"The plugin swaps tsconfig.json files in-place; if the process is interrupted, the original tsconfig.json may not be restored.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Explicitly list all workspace packages that need the alternate tsconfig.","message":"The workspaces option only affects listed packages; it does not automatically read the root's workspaces from package.json.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Place vite-plugin-tsconfig early in the plugins array.","message":"Plugin hooks may conflict with other Vite plugins that also manipulate tsconfig; order of plugins matters.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"search_vec":"'2.0.0':22 '7.1.5':53 'allow':33 'altern':9 'backup/restore':43 'break':25 'buildstart/buildend':29 'chang':26 'ci':16 'current':18 'differenti':32 'environ':17 'extern':68 'file':36 'filenam':11 'hook':30 'javascript':70 'key':31 'may':58 'migrat':27 'monorepo':14,41,66 'nativ':55 'necessari':64 'note':48 'optimizedeps.esbuildoptions.tsconfig':56 'option':57 'origin':46 'packag':39 'path':69 'per':37 'plugin':2,5,62,73 'releas':23 'remain':63 'specifi':7 'stabl':19 'suffic':59 'swap':34 'tsconfig':3,10,35,74 'tsconfig.json':47 'typescript':75 'use':12 'version':20 'vite':1,4,52,72 'vite-plugin':71 'workspac':38","created_at":"2026-04-27T17:07:40.237007+00:00","updated_at":"2026-04-27T17:07:40.237007+00:00","problems":[{"fix":"Install the package: npm install -D vite-plugin-tsconfig","cause":"Package not installed or incorrect import path.","error":"Error: Cannot find module 'vite-plugin-tsconfig'"},{"fix":"Use ES module import: import tsconfig from 'vite-plugin-tsconfig'","cause":"Using CommonJS require() instead of ESM import.","error":"TypeError: (0 , vite_plugin_tsconfig_1.default) is not a function"},{"fix":"Update Vite: npm install vite@latest","cause":"Installed Vite version is too old.","error":"Error: The plugin 'vite-plugin-tsconfig' requires Vite >= 3.1.6"},{"fix":"Ensure the file exists or create it. Check the filename option.","cause":"The specified alternate tsconfig file does not exist.","error":"Error: ENOENT: no such file or directory, open 'tsconfig.build.json'"},{"fix":"Add the workspace package name to the workspaces array.","cause":"Workspace package not listed in workspaces option.","error":"Error: Failed to resolve import path in workspace package due to tsconfig not being swapped"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":"","cli_version":null,"type":"library","homepage":null,"github":"https://github.com/alienfast/vite-plugin-tsconfig","docs":null,"changelog":null,"pypi":null,"npm":"https://www.npmjs.com/package/vite-plugin-tsconfig","openapi_spec":null,"status_page":null,"smithery":null,"categories":["devops"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-18","next_check":"2026-07-26","install_tag":null}}