Vite plugin to strip comments in production builds, with options to preserve legal comments or JSDoc. Current stable version is 0.0.10 (released 2025-03-17). Targets Node >=20, requires pnpm >=9.10.0 or Deno >=2.0.4. Compatible with Rollup, Rolldown, tsup, and tsdown. Differentiates from built-in minify by removing stubborn comments like istanbul ignore flags. Provides three stripping modes: all, keep-legal (default), and keep-jsdoc. Ships TypeScript types. Early stage (low version), use with caution. GitHub: https://github.com/thednp/vite-plugin-strip-comments.
npm install vite-plugin-strip-commentsVerified import paths — ran on the pinned version, not inferred.
Minimal Vite config using strip-comments plugin with keep-legal mode to preserve copyright/legal headers.
Enable only for production builds, disable other comment-stripping plugins to avoid double processing.
Update to at least version 0.0.9.
Set enforce to 'pre' to strip before other transforms, or 'post' for after.
Use exact string values as documented.
Install the package and ensure Node >=20.
Use default import: import strip from 'vite-plugin-strip-comments'
Call strip() without arguments or with a valid options object: strip({ type: 'keep-legal' })Use dynamic import(): const strip = await import('vite-plugin-strip-comments');No dependency data recorded yet.