A Vite plugin that adds a banner comment to the top of each generated chunk (JS and CSS files). Current stable version is 0.8.1, compatible with Vite 6. Released under active maintenance with monthly updates. Key differentiators: lightweight (no extra dependencies), supports string or callback-based banner content, allows debug mode and content verification toggle. Compared to alternatives like rollup-plugin-banner, it is Vite-native and supports ESM/CJS.
npm install vite-plugin-bannerVerified import paths — ran on the pinned version, not inferred.
Basic setup with a callback that adds file-specific banners to JS and CSS chunks.
Ensure your Vite config has build.outDir set, or manually pass outDir option to plugin.
Upgrade to v0.7.1+ or ensure callback always returns a non-empty string or null.
Set verify: false to skip content validation, or avoid problematic characters.
Use import banner from 'vite-plugin-banner' instead of require().
Switch to ESM: use import banner from 'vite-plugin-banner' and ensure vite.config.ts is processed as ESM.
Use correct options format: { content: '...' } or { content: (fileName) => '...' }.Set verify: false or sanitize content to avoid nested comment tokens.
No dependency data recorded yet.