From 2b9c38a2711ae639a26a63ddfdc57c10538f4696 Mon Sep 17 00:00:00 2001 From: Mehmet Samet Duman Date: Sun, 5 Apr 2026 00:06:22 +0300 Subject: NOISSUE update LESS compilation method to use Less JS API for improved compatibility Signed-off-by: Mehmet Samet Duman --- ofborg/ofborg-viewer/build.js | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/ofborg/ofborg-viewer/build.js b/ofborg/ofborg-viewer/build.js index bcdcbc889f..fd132cff3a 100644 --- a/ofborg/ofborg-viewer/build.js +++ b/ofborg/ofborg-viewer/build.js @@ -29,10 +29,22 @@ if (fs.existsSync(revFile)) { } const VERSION = JSON.parse(fs.readFileSync(path.join(ROOT, "package.json"), "utf-8")).version; -// 2. Compile LESS → CSS +// 2. Compile LESS → CSS using Less JS API (avoids ESM extensionless bin issue) console.log("Compiling LESS..."); const lessFile = path.join(ROOT, "src/styles/index.less"); -const cssOutput = execSync(`npx lessc ${lessFile}`, { encoding: "utf-8" }); +const helperFile = path.join(ROOT, ".less-compile.mjs"); +fs.writeFileSync(helperFile, ` +import less from "less"; +import { readFileSync } from "fs"; +const src = readFileSync(process.argv[2], "utf-8"); +const out = await less.render(src, { filename: process.argv[2] }); +process.stdout.write(out.css); +`); +const cssOutput = execSync(`node ${helperFile} ${lessFile}`, { + encoding: "utf-8", + cwd: ROOT, +}); +fs.unlinkSync(helperFile); // 3. Build JS bundle with esbuild console.log("Bundling JS..."); -- cgit 0.0.5-2-1-g0f52