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.
Files changed (2) hide show
  1. package/dist/index.js +5 -5
  2. 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
- for (const htmlFileName of Object.keys(bundle)) {
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 in assets) {
118
- // name: logo-XXXXXXXX.svg
119
- if (js.code.includes(name))
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?$/, ''));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vite-plugin-singlefile-compression",
3
- "version": "1.0.3",
3
+ "version": "1.0.4",
4
4
  "main": "dist/index.js",
5
5
  "typings": "dist/index.d.ts",
6
6
  "files": [