vite-plugin-singlefile-compression 1.0.3 → 1.0.4
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/dist/index.js +5 -5
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -54,7 +54,8 @@ async function generateBundle(bundle, htmlMinifierOptions) {
|
|
|
54
54
|
console.log(pc.cyan('\n\nvite-plugin-singlefile-compression ') + pc.green('building...'));
|
|
55
55
|
const globalDel = new Set();
|
|
56
56
|
const globalDoNotDel = new Set();
|
|
57
|
-
|
|
57
|
+
const bundleNames = Object.keys(bundle);
|
|
58
|
+
for (const htmlFileName of bundleNames) {
|
|
58
59
|
// key format:
|
|
59
60
|
// index.html
|
|
60
61
|
// assets/index-ZZZZZZZZ.js
|
|
@@ -114,10 +115,9 @@ async function generateBundle(bundle, htmlMinifierOptions) {
|
|
|
114
115
|
oldSize += js.code.length;
|
|
115
116
|
// fix new URL
|
|
116
117
|
newJSCode.push(`import.meta.url=location.origin+location.pathname.replace(/[^/]*$/,"${name}")`);
|
|
117
|
-
for (const name
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
globalDoNotDel.add("assets/" + name);
|
|
118
|
+
for (const name of bundleNames) {
|
|
119
|
+
if (name.startsWith('assets/') && js.code.includes(name.slice('assets/'.length)))
|
|
120
|
+
globalDoNotDel.add(name);
|
|
121
121
|
}
|
|
122
122
|
// add script
|
|
123
123
|
newJSCode.push(js.code.replace(/;?\n?$/, ''));
|