From fcc9b8d803f6c740c6d8156067720fb6fcc8bcf4 Mon Sep 17 00:00:00 2001 From: hh Date: Wed, 21 Aug 2024 12:37:15 +0330 Subject: [PATCH] fix: multiplatform support --- build/esbuild-build.ts | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/build/esbuild-build.ts b/build/esbuild-build.ts index 6745aa70..581c5792 100644 --- a/build/esbuild-build.ts +++ b/build/esbuild-build.ts @@ -1,6 +1,22 @@ import { execSync } from "child_process"; import { config } from "dotenv"; import esbuild from "esbuild"; +import { readFileSync, appendFileSync, writeFileSync } from "fs"; +import { join } from "path"; + +// CSS files in order +const cssFiles: string[] = [ + "static/styles/rewards/pay.css", + "static/styles/rewards/background.css", + "static/styles/toast.css", + "static/styles/rewards/claim-table.css", + "static/styles/rewards/media-queries.css", + "static/styles/rewards/light-mode.css", +]; + +// Output bundles file +const outputFilePath = "static/bundles/bundles.css"; + const typescriptEntries = ["static/scripts/rewards/init.ts"]; export const entries = [...typescriptEntries]; @@ -27,12 +43,14 @@ export const esBuildContext: esbuild.BuildOptions = { name: "css-bundle", setup(build) { build.onEnd((result) => { - execSync(`cat static/styles/rewards/pay.css > static/bundles/bundles.css`); - execSync(`cat static/styles/rewards/background.css >> static/bundles/bundles.css`); - execSync(`cat static/styles/toast.css >> static/bundles/bundles.css`); - execSync(`cat static/styles/rewards/claim-table.css >> static/bundles/bundles.css`); - execSync(`cat static/styles/rewards/media-queries.css >> static/bundles/bundles.css`); - execSync(`cat static/styles/rewards/light-mode.css >> static/bundles/bundles.css`); + // Clear the file first + writeFileSync(outputFilePath, "", "utf8"); + + // Concatenate each file into the bundles file + cssFiles.forEach((file) => { + const data = readFileSync(file, "utf8"); + appendFileSync(outputFilePath, data, "utf8"); + }); }); }, },