vite-plugin-singlefile-compression 2.2.4 → 2.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -5
- package/dist/index.d.ts +1 -1
- package/dist/index.js +7 -8
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -142,7 +142,7 @@ type: `boolean`
|
|
|
142
142
|
|
|
143
143
|
Use import.meta polyfill.
|
|
144
144
|
|
|
145
|
-
default: `
|
|
145
|
+
default: `false`
|
|
146
146
|
|
|
147
147
|
type: `boolean`
|
|
148
148
|
|
|
@@ -156,17 +156,17 @@ vite v8.0.8 building client environment for production...
|
|
|
156
156
|
✓ 42 modules transformed.
|
|
157
157
|
rendering chunks (1)...
|
|
158
158
|
|
|
159
|
-
vite-plugin-singlefile-compression 2.
|
|
159
|
+
vite-plugin-singlefile-compression 2.3.1 deflate-raw base128-ascii
|
|
160
160
|
|
|
161
161
|
file:///D:/code/js/vite-plugin-singlefile-compression/test/dist/index.html
|
|
162
|
-
122.
|
|
162
|
+
122.767 kB -> 50.111 kB
|
|
163
163
|
|
|
164
164
|
Finish.
|
|
165
165
|
|
|
166
166
|
computing gzip size...
|
|
167
|
-
dist/index.html 50.
|
|
167
|
+
dist/index.html 50.11 kB │ gzip: 43.67 kB
|
|
168
168
|
|
|
169
|
-
✓ built in
|
|
169
|
+
✓ built in 269ms
|
|
170
170
|
```
|
|
171
171
|
|
|
172
172
|
## Clone
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -9,7 +9,7 @@ import zlib from "zlib";
|
|
|
9
9
|
import svgToTinyDataUri from "mini-svg-data-uri";
|
|
10
10
|
import { lookup } from "mrmime";
|
|
11
11
|
//#region package.json
|
|
12
|
-
var version = "2.
|
|
12
|
+
var version = "2.3.1";
|
|
13
13
|
//#endregion
|
|
14
14
|
//#region src/compress.ts
|
|
15
15
|
const compressors = {
|
|
@@ -68,14 +68,14 @@ async function compress(format, buf, useBase128, compressor) {
|
|
|
68
68
|
const files = {
|
|
69
69
|
"assets": ["{let e=", ";for(let l in e)for(let r of document.querySelectorAll(`[src=\"data:${l}\"]`))r.src=e[l]}"],
|
|
70
70
|
"base128": [
|
|
71
|
-
"for(var e,
|
|
72
|
-
",
|
|
73
|
-
"))
|
|
71
|
+
"for(var e,n=",
|
|
72
|
+
",t=n.length,r=new Uint8Array(t/8*7),o=0,d=0,p=t=>(e=n.charCodeAt(o++))>127?e=0:e,_=Response,a=document.createElement(\"script\");o<t;)r[d++]=p()<<1|p()>>6,r[d++]=e<<2|p()>>5,r[d++]=e<<3|p()>>4,r[d++]=e<<4|p()>>3,r[d++]=e<<5|p()>>2,r[d++]=e<<6|p()>>1,r[d++]=e<<7|p();new _(new _(r).body.pipeThrough(new DecompressionStream(",
|
|
73
|
+
"))).text().then(e=>{a.type=\"module\",a.innerHTML=e,document.head.appendChild(a)})"
|
|
74
74
|
],
|
|
75
75
|
"base64": [
|
|
76
76
|
"fetch(\"data:;base64,",
|
|
77
77
|
"\").then(e=>new Response(e.body.pipeThrough(new DecompressionStream(",
|
|
78
|
-
"))
|
|
78
|
+
"))).text()).then(e=>{var t=document.createElement(\"script\");t.type=\"module\",t.innerHTML=e,document.head.appendChild(t)})"
|
|
79
79
|
],
|
|
80
80
|
"css": "document.head.appendChild(document.createElement(\"style\")).innerHTML=",
|
|
81
81
|
"icon": "document.querySelector(\"link[rel=icon]\").href=",
|
|
@@ -138,7 +138,7 @@ function getInnerOptions(opt) {
|
|
|
138
138
|
removeInlinedAssetFiles: opt.removeInlinedAssetFiles ?? true,
|
|
139
139
|
tryInlineHtmlPublicIcon: opt.tryInlineHtmlPublicIcon ?? true,
|
|
140
140
|
removeInlinedPublicIconFiles: opt.removeInlinedPublicIconFiles ?? true,
|
|
141
|
-
useImportMetaPolyfill: opt.useImportMetaPolyfill ??
|
|
141
|
+
useImportMetaPolyfill: opt.useImportMetaPolyfill ?? false
|
|
142
142
|
};
|
|
143
143
|
}
|
|
144
144
|
//#endregion
|
|
@@ -307,9 +307,8 @@ async function generateBundle(bundle, config, options) {
|
|
|
307
307
|
else newJSCode.push("var __VITE_PRELOAD__");
|
|
308
308
|
newJSCode.push(code);
|
|
309
309
|
} else inlineHtmlAssets();
|
|
310
|
-
let outputScript = newJSCode.join(";");
|
|
310
|
+
let outputScript = newJSCode.join(";").replaceAll("<\/script", "<\\/script");
|
|
311
311
|
if (options.enableCompress) outputScript = await template.base(outputScript, options.compressFormat, options.useBase128, options.compressor);
|
|
312
|
-
else outputScript = outputScript.replaceAll("<\/script", "<\\/script");
|
|
313
312
|
htmlChunk.source = htmlChunk.source.replace(fakeScript, () => outputScript);
|
|
314
313
|
console.log(" " + pc.gray(kB(oldSize) + " -> ") + pc.cyanBright(kB(Buffer.byteLength(htmlChunk.source))) + "\n");
|
|
315
314
|
for (const name of thisDel) globalDelete.add(name);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vite-plugin-singlefile-compression",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.3.1",
|
|
4
4
|
"author": "bddjr",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"description": "Compress all assets and embeds them into dist/index.html, making it convenient to share as a single HTML file.",
|
|
@@ -89,7 +89,7 @@
|
|
|
89
89
|
},
|
|
90
90
|
"dependencies": {
|
|
91
91
|
"@types/html-minifier-terser": ">=7.0.2",
|
|
92
|
-
"base128-ascii": "
|
|
92
|
+
"base128-ascii": ">=3.0.0",
|
|
93
93
|
"html-minifier-terser": ">=7.2.0",
|
|
94
94
|
"jsdom": ">=29.0.2",
|
|
95
95
|
"mini-svg-data-uri": ">=1.4.4",
|
|
@@ -98,11 +98,11 @@
|
|
|
98
98
|
},
|
|
99
99
|
"devDependencies": {
|
|
100
100
|
"@types/jsdom": ">=28.0.1",
|
|
101
|
-
"@types/node": "^
|
|
101
|
+
"@types/node": "^24.12.2",
|
|
102
102
|
"rolldown": ">=1.0.0-rc.15",
|
|
103
|
-
"rolldown-plugin-dts": ">=0.
|
|
103
|
+
"rolldown-plugin-dts": ">=0.23.2",
|
|
104
104
|
"terser": ">=5.46.1",
|
|
105
105
|
"typescript": ">=6.0.2",
|
|
106
106
|
"vite": ">=8.0.8"
|
|
107
107
|
}
|
|
108
|
-
}
|
|
108
|
+
}
|