Vite plugin to generate TypeScript type definitions (.d.ts) for libraries and applications. Current stable version is 1.2.0, with monthly or bi-monthly releases. Zero-dependency plugin that wraps the TypeScript compiler (tsc) in a Vite plugin, generating declaration files on build. Differentiators: minimal configuration, no external dependencies, supports custom tsc binary, outDir, tsConfig, and additional tsc arguments. Ideal for library authors wanting a lightweight alternative to heavier plugins like vite-plugin-dts.
npm install vite-dts-pluginVerified import paths — ran on the pinned version, not inferred.
Configures Vite with the dtsPlugin for a library build, generating type declarations in the dist folder.
Ensure outDir is same as Vite's build.outDir (default 'dist').
Add 'typescript' as a devDependency.
Pass a string filename (e.g., 'tsconfig.build.json') or leave undefined to use default tsconfig.
Only pass known tsc options, e.g., ['--declaration', '--emitDeclarationOnly'].
Run 'npm install --save-dev typescript'.
Install TypeScript and ensure node_modules/.bin is in PATH, or specify a custom tsc path with the 'tsc' option.
Use named import: import { dtsPlugin } from 'vite-dts-plugin'.