Skip to content

Commit a1a02ba

Browse files
committed
fix: zip path code error
1 parent 7f74f5b commit a1a02ba

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

plugins/zip.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,13 @@ export const zip = (zipOption: ZipOption = {}): Plugin => {
2828
async closeBundle() {
2929
const zip = new JSZIP();
3030
for await (const fp of walk(`dist`)) {
31-
zip.file(fp.substring(5), fs.readFile(fp));
31+
/**
32+
* must use .replaceAll('\\\\', '/')
33+
*
34+
* ![image](https://github.com/lisonge/Disable-CSP/assets/38517192/64292207-9a8b-4b1a-861c-8f634c851009)
35+
*/
36+
const pathname = fp.substring(`dist/`.length).replaceAll(`\\`, `/`);
37+
zip.file(pathname, fs.readFile(fp));
3238
}
3339
const bf = await zip.generateAsync({ type: 'nodebuffer' });
3440
fs.writeFile(`dist.zip`, bf);

0 commit comments

Comments
 (0)