Skip to content

Commit

Permalink
1.1.0 add options
Browse files Browse the repository at this point in the history
tryInlineHtmlAssets
removeInlinedAssetFiles
tryInlineHtmlPublicIcon
removeInlinedPublicIconFiles
  • Loading branch information
bddjr committed Nov 29, 2024
1 parent 0201752 commit b45b492
Show file tree
Hide file tree
Showing 5 changed files with 283 additions and 66 deletions.
36 changes: 30 additions & 6 deletions README-zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,31 @@ export interface Options {
* https://github.com/terser/html-minifier-terser?tab=readme-ov-file#options-quick-reference
* @default defaultHtmlMinifierTerserOptions
*/
htmlMinifierTerser?: htmlMinifierOptions | true | false
htmlMinifierTerser?: htmlMinifierOptions | boolean

/**
* 尝试内联 html 用到的资源,如果在 JS 里被内联或未使用。
* @default true
*/
tryInlineHtmlAssets?: boolean

/**
* 移除已内联的资源文件。
* @default true
*/
removeInlinedAssetFiles?: boolean

/**
* 尝试内联 html 的图标,如果图标在 public 文件夹。
* @default true
*/
tryInlineHtmlPublicIcon?: boolean

/**
* 移除已内联的 html 图标文件。
* @default true
*/
removeInlinedPublicIconFiles?: boolean
}
```
Expand All @@ -75,19 +99,19 @@ vite v5.4.11 building for production...
45 modules transformed.
rendering chunks (1)...

vite-plugin-singlefile-compression building...
vite-plugin-singlefile-compression 1.1.0 building...

file:///D:/bddjr/Desktop/code/js/vite-plugin-singlefile-compression/test/dist/index.html
97.52 KiB -> 50.98 KiB
101.43 KiB -> 52.35 KiB

Finish.

dist/index.html 52.19 kB
built in 685ms
dist/index.html 53.60 kB
built in 678ms
```
```html
<!DOCTYPE html><meta charset=UTF-8><link rel=icon href=data:logo-_cUAdIX-.svg><meta name=viewport content="width=device-width,initial-scale=1"><title>Vite App</title><script type=module>fetch("data:application/gzip;base64,H4sI********hAEA").then(r=>r.blob()).then(b=>new Response(b.stream().pipeThrough(new DecompressionStream("gzip")),{headers:{"Content-Type":"text/javascript"}}).blob()).then(b=>import(b=URL.createObjectURL(b)).finally(()=>URL.revokeObjectURL(b)))</script><div id=app></div>
<!DOCTYPE html><meta charset=UTF-8><link rel=icon href=data:><meta name=viewport content="width=device-width,initial-scale=1"><title>Vite App</title><script type=module>fetch("data:application/gzip;base64,********").then(r=>r.blob()).then(b=>new Response(b.stream().pipeThrough(new DecompressionStream("gzip")),{headers:{"Content-Type":"text/javascript"}}).blob()).then(b=>import(b=URL.createObjectURL(b)).finally(()=>URL.revokeObjectURL(b)))</script><div id=app></div>
```
## Clone
Expand Down
36 changes: 30 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,31 @@ export interface Options {
* https://github.com/terser/html-minifier-terser?tab=readme-ov-file#options-quick-reference
* @default defaultHtmlMinifierTerserOptions
*/
htmlMinifierTerser?: htmlMinifierOptions | true | false
htmlMinifierTerser?: htmlMinifierOptions | boolean

/**
* Try inline html used assets, if inlined or not used in JS.
* @default true
*/
tryInlineHtmlAssets?: boolean

/**
* Remove inlined asset files.
* @default true
*/
removeInlinedAssetFiles?: boolean

/**
* Try inline html icon, if icon is in public dir.
* @default true
*/
tryInlineHtmlPublicIcon?: boolean

/**
* Remove inlined html icon files.
* @default true
*/
removeInlinedPublicIconFiles?: boolean
}
```
Expand All @@ -75,19 +99,19 @@ vite v5.4.11 building for production...
45 modules transformed.
rendering chunks (1)...

vite-plugin-singlefile-compression building...
vite-plugin-singlefile-compression 1.1.0 building...

file:///D:/bddjr/Desktop/code/js/vite-plugin-singlefile-compression/test/dist/index.html
97.52 KiB -> 50.98 KiB
101.43 KiB -> 52.35 KiB

Finish.

dist/index.html 52.19 kB
built in 685ms
dist/index.html 53.60 kB
built in 678ms
```
```html
<!DOCTYPE html><meta charset=UTF-8><link rel=icon href=data:logo-_cUAdIX-.svg><meta name=viewport content="width=device-width,initial-scale=1"><title>Vite App</title><script type=module>fetch("data:application/gzip;base64,H4sI********hAEA").then(r=>r.blob()).then(b=>new Response(b.stream().pipeThrough(new DecompressionStream("gzip")),{headers:{"Content-Type":"text/javascript"}}).blob()).then(b=>import(b=URL.createObjectURL(b)).finally(()=>URL.revokeObjectURL(b)))</script><div id=app></div>
<!DOCTYPE html><meta charset=UTF-8><link rel=icon href=data:><meta name=viewport content="width=device-width,initial-scale=1"><title>Vite App</title><script type=module>fetch("data:application/gzip;base64,********").then(r=>r.blob()).then(b=>new Response(b.stream().pipeThrough(new DecompressionStream("gzip")),{headers:{"Content-Type":"text/javascript"}}).blob()).then(b=>import(b=URL.createObjectURL(b)).finally(()=>URL.revokeObjectURL(b)))</script><div id=app></div>
```
## Clone
Expand Down
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "vite-plugin-singlefile-compression",
"version": "1.0.5",
"version": "1.1.0",
"main": "dist/index.js",
"typings": "dist/index.d.ts",
"files": [
Expand All @@ -23,7 +23,9 @@
"url": "https://github.com/bddjr/vite-plugin-singlefile-compression"
},
"keywords": [
"vite-plugin",
"vite",
"plugin",
"SFA",
"single-file",
"singlefile",
Expand Down
Loading

0 comments on commit b45b492

Please sign in to comment.