Registry / devops / vite-plugin-tsconfig

vite-plugin-tsconfig

JSON →
library2.0.0jsnpmunverified

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.

npm install vite-plugin-tsconfig
INSTALL
IMPORT
SIG · VITE-PLUGIN-TSCONF
V
vite-plugin-tsconfig
devopsjavascriptv2.0.0
Install
—
Import
—
Disk
—
Pass rate
0/ 6
Env Coverage0 / 6
glibc
18–22
musl
18–22
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18–223 runs
build_error
glibc
node 18–223 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

tsconfig
✓ import tsconfig from 'vite-plugin-tsconfig'
✗ const tsconfig = require('vite-plugin-tsconfig')
Default export; ESM-only.
tsconfig (with type import)
✓ import tsconfig from 'vite-plugin-tsconfig'
TypeScript types are shipped; use default import.
PluginOptions
✓ import type { PluginOptions } from 'vite-plugin-tsconfig'
✗ import { PluginOptions } from 'vite-plugin-tsconfig'
Type-only export; import type is recommended.

Configures Vite to use an alternate tsconfig file during build, with optional workspace packages for monorepos.

import { defineConfig } from 'vite'; import tsconfig from 'vite-plugin-tsconfig'; export default defineConfig({ plugins: [ tsconfig({ filename: 'tsconfig.build.json', logLevel: 'info', workspaces: ['packages/ui', 'packages/notifications'], }), ], });
Debug
Known issues
breakingv2.0.0 migrated from configResolved/buildStart hooks to buildStart/buildEnd hooks, which may affect plugin ordering and lifecycle timing.
fix
Update plugin configuration if relying on specific hook behavior; in most cases no code changes are needed.
affects: >=2.0.0
deprecatedPlugin may be unnecessary for typical use cases as of Vite 7.1.5, which supports optimizeDeps.esbuildOptions.tsconfig natively.
fix
Consider removing the plugin and using Vite's native esbuildOptions.tsconfig.
affects: >=2.0.0
gotchaThe plugin swaps tsconfig.json files in-place; if the process is interrupted, the original tsconfig.json may not be restored.
fix
Ensure proper error handling or have version control to recover the original tsconfig.json.
affects: >=1.0.0
gotchaThe workspaces option only affects listed packages; it does not automatically read the root's workspaces from package.json.
fix
Explicitly list all workspace packages that need the alternate tsconfig.
affects: >=1.0.0
gotchaPlugin hooks may conflict with other Vite plugins that also manipulate tsconfig; order of plugins matters.
fix
Place vite-plugin-tsconfig early in the plugins array.
affects: >=1.0.0
Errors
Common errors & fixes
Error: Cannot find module 'vite-plugin-tsconfig'
Package not installed or incorrect import path.
fix
Install the package: npm install -D vite-plugin-tsconfig
TypeError: (0 , vite_plugin_tsconfig_1.default) is not a function
Using CommonJS require() instead of ESM import.
fix
Use ES module import: import tsconfig from 'vite-plugin-tsconfig'
Error: The plugin 'vite-plugin-tsconfig' requires Vite >= 3.1.6
Installed Vite version is too old.
fix
Update Vite: npm install vite@latest
Error: ENOENT: no such file or directory, open 'tsconfig.build.json'
The specified alternate tsconfig file does not exist.
fix
Ensure the file exists or create it. Check the filename option.
Error: Failed to resolve import path in workspace package due to tsconfig not being swapped
Workspace package not listed in workspaces option.
fix
Add the workspace package name to the workspaces array.
Upgrade
Version history
2.0.0latest on npm
Audit
Dependencies
viteoptionalPeer dependency - requires Vite >=3.1.6
Agent activity
4 hits · last 30 days
node
4
Resources
vite-plugin-tsconfig — npm install vite-plugin-tsconfig · libregistry