{"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,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","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,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}