vite-plugin-minify
Advanced tools
Comparing version
import { Plugin } from 'vite'; | ||
import { Options } from 'html-minifier-terser'; | ||
/** | ||
* @param options [html-minifier-terser options](https://github.com/terser/html-minifier-terser?tab=readme-ov-file#options-quick-reference) | ||
* | ||
* @default | ||
* | ||
* { | ||
* removeComments: true, | ||
* collapseWhitespace: true, | ||
* collapseBooleanAttributes: true, | ||
* removeAttributeQuotes: false, | ||
* removeEmptyAttributes: true, | ||
* minifyCSS: true, | ||
* minifyJS: true, | ||
* minifyURLs: true, | ||
* ...options, // user provided options | ||
* } | ||
* | ||
* @returns vite-plugin-minify | ||
*/ | ||
declare function ViteMinifyPlugin(options?: Options): Plugin; | ||
export { ViteMinifyPlugin, ViteMinifyPlugin as default }; |
@@ -1,2 +0,2 @@ | ||
var n=Object.defineProperty;var a=Object.getOwnPropertyDescriptor;var y=Object.getOwnPropertyNames,u=Object.getOwnPropertySymbols;var l=Object.prototype.hasOwnProperty,c=Object.prototype.propertyIsEnumerable;var m=(t,e,i)=>e in t?n(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,p=(t,e)=>{for(var i in e||(e={}))l.call(e,i)&&m(t,i,e[i]);if(u)for(var i of u(e))c.call(e,i)&&m(t,i,e[i]);return t};var b=(t,e)=>{for(var i in e)n(t,i,{get:e[i],enumerable:!0})},g=(t,e,i,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of y(e))!l.call(t,r)&&r!==i&&n(t,r,{get:()=>e[r],enumerable:!(o=a(e,r))||o.enumerable});return t};var v=t=>g(n({},"__esModule",{value:!0}),t);var x={};b(x,{ViteMinifyPlugin:()=>s,default:()=>d});module.exports=v(x);var f=require("html-minifier-terser");function s(t){return{name:"vite-plugin-minify",enforce:"post",apply:"build",transformIndexHtml:e=>(0,f.minify)(e,p({removeComments:!0,collapseWhitespace:!0,collapseBooleanAttributes:!0,removeAttributeQuotes:!1,removeEmptyAttributes:!0,minifyCSS:!0,minifyJS:!0,minifyURLs:!0},t))}}var d=s;0&&(module.exports={ViteMinifyPlugin}); | ||
import{minify as i}from"html-minifier-terser";function r(e){return{name:"vite-plugin-minify",apply:"build",transformIndexHtml:{order:"post",handler(t){return i(t,{removeComments:!0,collapseWhitespace:!0,collapseBooleanAttributes:!0,removeAttributeQuotes:!1,removeEmptyAttributes:!0,minifyCSS:!0,minifyJS:!0,minifyURLs:!0,...e})}}}}var u=r;export{r as ViteMinifyPlugin,u as default}; | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "vite-plugin-minify", | ||
"version": "1.5.2", | ||
"version": "2.0.0", | ||
"description": "Minify html in production", | ||
"main": "dist/index.js", | ||
"module": "dist/index.mjs", | ||
"type": "module", | ||
"main": "dist/index.cjs", | ||
"module": "dist/index.js", | ||
"types": "dist/index.d.ts", | ||
"scripts": { | ||
"build": "tsup" | ||
"format": "prettier --write .", | ||
"build": "npm run format && tsup" | ||
}, | ||
@@ -26,13 +28,15 @@ "author": "zhuweiyou <i@zhuweiyou.com>", | ||
"dependencies": { | ||
"html-minifier-terser": "^6.1.0" | ||
"@types/html-minifier-terser": "^7.0.2", | ||
"html-minifier-terser": "^7.2.0" | ||
}, | ||
"devDependencies": { | ||
"@types/html-minifier-terser": "^6.1.0", | ||
"@types/node": "^17.0.36", | ||
"tsup": "^6.0.1", | ||
"vite": "*" | ||
"@types/node": "^22.1.0", | ||
"prettier": "^3.3.3", | ||
"tsup": "^8.2.4", | ||
"typescript": "^5.5.4", | ||
"vite": "^5.4.0" | ||
}, | ||
"peerDependencies": { | ||
"vite": "*" | ||
"vite": "^5.4.0" | ||
} | ||
} |
@@ -0,0 +0,0 @@ # vite-plugin-minify |
import { Plugin } from 'vite' | ||
import { minify, Options } from 'html-minifier-terser' | ||
/** | ||
* @param options [html-minifier-terser options](https://github.com/terser/html-minifier-terser?tab=readme-ov-file#options-quick-reference) | ||
* | ||
* @default | ||
* | ||
* { | ||
* removeComments: true, | ||
* collapseWhitespace: true, | ||
* collapseBooleanAttributes: true, | ||
* removeAttributeQuotes: false, | ||
* removeEmptyAttributes: true, | ||
* minifyCSS: true, | ||
* minifyJS: true, | ||
* minifyURLs: true, | ||
* ...options, // user provided options | ||
* } | ||
* | ||
* @returns vite-plugin-minify | ||
*/ | ||
export function ViteMinifyPlugin(options?: Options): Plugin { | ||
return { | ||
name: 'vite-plugin-minify', | ||
enforce: 'post', | ||
apply: 'build', | ||
transformIndexHtml: (html) => { | ||
return minify(html, { | ||
removeComments: true, | ||
collapseWhitespace: true, | ||
collapseBooleanAttributes: true, | ||
removeAttributeQuotes: false, | ||
removeEmptyAttributes: true, | ||
minifyCSS: true, | ||
minifyJS: true, | ||
minifyURLs: true, | ||
...options, | ||
}) | ||
transformIndexHtml: { | ||
order: 'post', | ||
handler(html) { | ||
return minify(html, { | ||
removeComments: true, | ||
collapseWhitespace: true, | ||
collapseBooleanAttributes: true, | ||
removeAttributeQuotes: false, | ||
removeEmptyAttributes: true, | ||
minifyCSS: true, | ||
minifyJS: true, | ||
minifyURLs: true, | ||
...options, | ||
}) | ||
}, | ||
}, | ||
@@ -22,0 +43,0 @@ } |
@@ -0,0 +0,0 @@ { |
@@ -0,0 +0,0 @@ import { defineConfig } from 'tsup' |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 2 instances in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
10539
40.54%14
27.27%99
80%Yes
NaN3
50%5
25%2
100%+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
Updated