Skip to content

Commit

Permalink
fix globalDoNotDel
Browse files Browse the repository at this point in the history
  • Loading branch information
bddjr committed Nov 27, 2024
1 parent 87e9103 commit 32b9e81
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,9 +156,10 @@ async function generateBundle(bundle: OutputBundle, htmlMinifierOptions: htmlMin
oldSize += js.code.length
// fix new URL
newJSCode.push(`import.meta.url=location.origin+location.pathname.replace(/[^/]*$/,"${name}")`)
for (const i in assets) {
if (js.code.includes(i))
globalDoNotDel.add(i)
for (const name in assets) {
// name: logo-XXXXXXXX.svg
if (js.code.includes(name))
globalDoNotDel.add("assets/" + name)
}
// add script
newJSCode.push(js.code.replace(/;?\n?$/, ''))
Expand Down

0 comments on commit 32b9e81

Please sign in to comment.