vite-plugin-license
raw JSON → 0.0.2 verified Mon Apr 27 auth: no javascript
Vite plugin to add license banners to bundled output. Current stable version is 0.0.2 (November 2025), released on a cadence of roughly every 7 months. It is a thin wrapper around rollup-plugin-license that resolves compatibility issues with Vite's build pipeline. Key differentiators: seamless integration with Vite's configuration and plugin system; supports customizable banner comment style and content from file or inline; includes TypeScript type definitions. Compared to using rollup-plugin-license directly, this plugin handles Vite-specific nuances such as virtual module IDs and hooks.
Common errors
error Cannot find module 'vite-plugin-license' or its corresponding type declarations. ↓
cause TypeScript cannot resolve the module because types are not installed or package is missing.
fix
Run 'npm install vite-plugin-license' and ensure tsconfig includes 'moduleResolution': 'node' or 'bundler'.
error TypeError: license is not a function ↓
cause Using a named import instead of default import.
fix
Change to 'import license from 'vite-plugin-license''.
error Error: The plugin 'vite-plugin-license' requires peer vite@^7.1.12 but you have an older version. ↓
cause Installed Vite version does not satisfy peer dependency.
fix
Upgrade Vite: 'npm install vite@^7.1.12'.
Warnings
breaking Peer dependency requirement: vite ^7.1.12. This plugin will not work with older Vite versions. ↓
fix Upgrade vite to ^7.1.12 or later.
deprecated If you previously used rollup-plugin-license directly in Vite, that approach may have issues with virtual modules; this plugin is the recommended replacement. ↓
fix Replace rollup-plugin-license with vite-plugin-license.
gotcha The default import is not a named export. Using 'import { license }' will result in undefined. ↓
fix Use 'import license from 'vite-plugin-license''.
Install
npm install vite-plugin-license yarn add vite-plugin-license pnpm add vite-plugin-license Imports
- default wrong
import { license } from 'vite-plugin-license'correctimport license from 'vite-plugin-license' - LicenseOptions
import type { LicenseOptions } from 'vite-plugin-license' - VitePluginLicense
import type { VitePluginLicense } from 'vite-plugin-license'
Quickstart
import path from 'node:path';
import { defineConfig } from 'vite';
import license from 'vite-plugin-license';
export default defineConfig({
plugins: [
license({
banner: {
commentStyle: 'regular',
content: {
file: path.join(__dirname, 'LICENSE'),
},
},
}),
],
});