Detalhes do pacote

vite-plugin-strip-comments

thednp1.4kMIT0.0.5

🗃️ Vite plugin for stripping comments in production builds

vite, strip, comments

readme (leia-me)

vite-plugin-strip-comments

Coverage Status ci NPM Version NPM Downloads typescript version vitest version vite version

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.

Install

pnpm install -D vite-plugin-strip-comments
yarn add -D vite-plugin-strip-comments
npm install -D vite-plugin-strip-comments
deno add -D npm:vite-plugin-strip-comments@latest

Usage

// vite.config.mts
import stripComments from 'vite-plugin-strip-comments';

export default defineConfig({
  plugins: [
    // ... other plugins
    stripComments({ type: 'none' }),
    // 'none' means to keep no comments
  ],
});

Options

  • type: "none" | "keep-legal" (default) - changes the behavior of the transform function
    • none removes all comments
    • keep-legal remove all commments except those which contain @legal or @license, a very good practice to allow open source to shine yes?
  • 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.