Registry / devops / vite-plugin-strip-comments

vite-plugin-strip-comments

JSON →
library0.0.10jsnpmunverified

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-comments
INSTALL
IMPORT
SIG · VITE-PLUGIN-STRIP-
V
vite-plugin-strip-comments
devopsjavascriptv0.0.10
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
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 18223 runs
build_error
glibc
node 18223 runs
build_error
Code
Verified usage

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

strip
import strip from 'vite-plugin-strip-comments'
const strip = require('vite-plugin-strip-comments')
ESM-only package; dynamic import via import() works; named import not supported.
strip
import strip from 'vite-plugin-strip-comments'
import { strip } from 'vite-plugin-strip-comments'
Default export only; braces cause undefined.
strip
import strip from 'vite-plugin-strip-comments'
import { default as strip } from 'vite-plugin-strip-comments'
Unnecessary but works; simpler to use default import.

Minimal Vite config using strip-comments plugin with keep-legal mode to preserve copyright/legal headers.

// vite.config.ts import { defineConfig } from 'vite' import strip from 'vite-plugin-strip-comments' export default defineConfig({ plugins: [ strip({ type: 'keep-legal', enforce: 'pre' }) ] })
Debug
Known issues
gotchaPlugin is experimental; may strip important comments or cause build issues. Test thoroughly.
fix
Enable only for production builds, disable other comment-stripping plugins to avoid double processing.
affects: <=0.0.10
gotchaDoes not respect /*! legal comment marker correctly before v0.0.9; use v0.0.9+.
fix
Update to at least version 0.0.9.
affects: <0.0.9
gotchaEnforce option only accepts 'pre' (default) or 'post'; misconfiguration may cause unintended order.
fix
Set enforce to 'pre' to strip before other transforms, or 'post' for after.
affects: >=0.0.7
gotchaType option expects exact strings: 'none', 'keep-legal', or 'keep-jsdoc'; typos are silently ignored.
fix
Use exact string values as documented.
affects: >=0.0.7
Errors
Common errors & fixes
Error: Module not found: Error: Can't resolve 'vite-plugin-strip-comments'
Package not installed or version incompatible with Node <20.
fix
Install the package and ensure Node >=20.
TypeError: strip is not a function
Named import used instead of default import.
fix
Use default import: import strip from 'vite-plugin-strip-comments'
TypeError: Cannot read properties of undefined (reading 'type')
Options object passed incorrectly as empty or invalid.
fix
Call strip() without arguments or with a valid options object: strip({ type: 'keep-legal' })
Unexpected token 'export'
Using require() in a CommonJS context; package is ESM-only.
fix
Use dynamic import(): const strip = await import('vite-plugin-strip-comments');
Upgrade
Version history
0.0.10latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
2 hits · last 30 days
node
2
Resources
vite-plugin-strip-comments — npm install vite-plugin-strip-comments · libregistry