vite-plugin-strip-comments
v0.0.2
Published
🗃️ Vite plugin for stripping comments in production builds
Downloads
117
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.
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: 'istanbul' }),
],
});
Options
- type: "none" | "keep-legal" | "istanbul" (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? - istanbul (default) only remove comments that target istanbul code coverage instrumentation (EG:
/* istanbul ignore else @preserve */
)
- 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.