From 8de05d87b554b0e0afb39976167618a90a699769 Mon Sep 17 00:00:00 2001 From: Dorian Niemiec Date: Tue, 27 Aug 2024 10:38:26 +0200 Subject: [PATCH] Make the build script not pack two "svr.js" files in the zip file. --- esbuild.config.js | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/esbuild.config.js b/esbuild.config.js index c7b8851..39b573c 100644 --- a/esbuild.config.js +++ b/esbuild.config.js @@ -214,7 +214,20 @@ esbuild zlib: { level: 9 }, }); archive.pipe(output); - archive.directory(__dirname + "/dist/", false); + + // Add everything in the "dist" directory except for "svr.js" and "svr.compressed" + const distFilesAndDirectories = fs.existsSync(__dirname + "/dist") + ? fs.readdirSync(__dirname + "/dist") + : []; + distFilesAndDirectories.forEach((entry) => { + if (entry == "svr.js" || entry == "svr.compressed") return; + const stats = fs.statSync(__dirname + "/dist/" + entry); + if (stats.isDirectory()) { + archive.directory(__dirname + "/dist/" + entry, entry); + } else if (stats.isFile()) { + archive.file(__dirname + "/dist/" + entry, { name: entry }); + } + }); // Create a stream for the "svr.compressed" file const compressedSVRJSFileStream = fs