vite-plugin-strip-comments
v0.0.9
Published
🗃️ Vite plugin for stripping comments in production builds
Downloads
6,682
Maintainers
Readme
vite-plugin-strip-comments
A very simple Vite plugin for stripping comments in your production code. Some comments just don't get removed no matter what minify options you set, especially /* istanbul ignore */ flags. Keep in mind this is experimental, please use with caution.
NOTES
- this plugin should be compatible with rollup, rolldown, tsup and tsdown as well.
- make sure to disable other plugins or options to strip comment to prevent overprocessing and long build times.
Install
pnpm install -D vite-plugin-strip-commentsyarn add -D vite-plugin-strip-commentsnpm install -D vite-plugin-strip-commentsdeno add -D npm:vite-plugin-strip-comments@latestUsage
Configuration
// vite.config.ts
// tsdown.config.ts
// rolldown.config.ts
import { defineConfig } from "vite"; // or tsdown | rolldown
import strip from 'vite-plugin-strip-comments';
export default defineConfig({
plugins: [
// ... other plugins
strip(),
// using default configuration
],
});Options
type: "none" | "keep-jsdoc" | "keep-legal" (default) - changes the behavior of the transform function- none removes all comments
- keep-legal remove all commments except those which contain
@copyright,@legalor@license, a very good practice to allow open source to shine yes? - keep-jsdoc remove all commments except legal (described above) and JSDoc
enforce: "pre" (default) | "post" - determines where in the compilation pipeline the plugin should work;
Contributions
- Found a problem, report the problem. Thank you!
- Found a fix? Clone, install, apply fix and commit. Thank you!
License
vite-plugin-strip-comments is released under the MIT License.
