vite-plugin-minify
Advanced tools
Comparing version 1.5.2 to 2.0.0
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance 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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance 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
14
99
Yes
3
5
+ Added@esbuild/aix-ppc64@0.21.5(transitive)
+ Added@esbuild/android-arm@0.21.5(transitive)
+ Added@esbuild/android-arm64@0.21.5(transitive)
+ Added@esbuild/android-x64@0.21.5(transitive)
+ Added@esbuild/darwin-arm64@0.21.5(transitive)
+ Added@esbuild/darwin-x64@0.21.5(transitive)
+ Added@esbuild/freebsd-arm64@0.21.5(transitive)
+ Added@esbuild/freebsd-x64@0.21.5(transitive)
+ Added@esbuild/linux-arm@0.21.5(transitive)
+ Added@esbuild/linux-arm64@0.21.5(transitive)
+ Added@esbuild/linux-ia32@0.21.5(transitive)
+ Added@esbuild/linux-loong64@0.21.5(transitive)
+ Added@esbuild/linux-mips64el@0.21.5(transitive)
+ Added@esbuild/linux-ppc64@0.21.5(transitive)
+ Added@esbuild/linux-riscv64@0.21.5(transitive)
+ Added@esbuild/linux-s390x@0.21.5(transitive)
+ Added@esbuild/linux-x64@0.21.5(transitive)
+ Added@esbuild/netbsd-x64@0.21.5(transitive)
+ Added@esbuild/openbsd-x64@0.21.5(transitive)
+ Added@esbuild/sunos-x64@0.21.5(transitive)
+ Added@esbuild/win32-arm64@0.21.5(transitive)
+ Added@esbuild/win32-ia32@0.21.5(transitive)
+ Added@esbuild/win32-x64@0.21.5(transitive)
+ Added@types/html-minifier-terser@7.0.2(transitive)
+ Addedcommander@10.0.1(transitive)
+ Addedentities@4.5.0(transitive)
+ Addedesbuild@0.21.5(transitive)
+ Addedhtml-minifier-terser@7.2.0(transitive)
+ Addedvite@5.4.11(transitive)
- Removed@esbuild/aix-ppc64@0.24.0(transitive)
- Removed@esbuild/android-arm@0.24.0(transitive)
- Removed@esbuild/android-arm64@0.24.0(transitive)
- Removed@esbuild/android-x64@0.24.0(transitive)
- Removed@esbuild/darwin-arm64@0.24.0(transitive)
- Removed@esbuild/darwin-x64@0.24.0(transitive)
- Removed@esbuild/freebsd-arm64@0.24.0(transitive)
- Removed@esbuild/freebsd-x64@0.24.0(transitive)
- Removed@esbuild/linux-arm@0.24.0(transitive)
- Removed@esbuild/linux-arm64@0.24.0(transitive)
- Removed@esbuild/linux-ia32@0.24.0(transitive)
- Removed@esbuild/linux-loong64@0.24.0(transitive)
- Removed@esbuild/linux-mips64el@0.24.0(transitive)
- Removed@esbuild/linux-ppc64@0.24.0(transitive)
- Removed@esbuild/linux-riscv64@0.24.0(transitive)
- Removed@esbuild/linux-s390x@0.24.0(transitive)
- Removed@esbuild/linux-x64@0.24.0(transitive)
- Removed@esbuild/netbsd-x64@0.24.0(transitive)
- Removed@esbuild/openbsd-arm64@0.24.0(transitive)
- Removed@esbuild/openbsd-x64@0.24.0(transitive)
- Removed@esbuild/sunos-x64@0.24.0(transitive)
- Removed@esbuild/win32-arm64@0.24.0(transitive)
- Removed@esbuild/win32-ia32@0.24.0(transitive)
- Removed@esbuild/win32-x64@0.24.0(transitive)
- Removedcommander@8.3.0(transitive)
- Removedesbuild@0.24.0(transitive)
- Removedhe@1.2.0(transitive)
- Removedhtml-minifier-terser@6.1.0(transitive)
- Removedvite@6.0.1(transitive)
Updatedhtml-minifier-terser@^7.2.0