richardtallent / vite-plugin-singlefile

Vite plugin for inlining JavaScript and CSS resources
MIT License
808 stars 53 forks source link

replaceScript method is "__VITE_PRELOAD__" replace first only. #55

Closed juner closed 1 year ago

juner commented 2 years ago

replace() is replace first target.

https://github.com/richardtallent/vite-plugin-singlefile/blob/5516a454d54d297219881d4e73df22a2a0b4560f/src/index.ts#L23-L29

It seems to me that replaceAll() should be used.

https://github.com/richardtallent/vite-plugin-singlefile/blob/5516a454d54d297219881d4e73df22a2a0b4560f/src/index.ts#L26

    const newCode = scriptCode.replaceAll(preloadMarker, "void 0")
richardtallent commented 1 year ago

Change made, will be in the next release

juner commented 1 year ago

@richardtallent thank you very much!

juner commented 1 year ago

The commit containing this correspondence is here. https://github.com/richardtallent/vite-plugin-singlefile/commit/886cdd720b85fb4fc34f1dc2bb56eb3a1e24195c