diff --git a/frontend/scripts/_helpers.js b/frontend/scripts/_helpers.js index a84057a396..4b72301e83 100644 --- a/frontend/scripts/_helpers.js +++ b/frontend/scripts/_helpers.js @@ -27,6 +27,8 @@ export function startWorker() { }); } +export const isDebug = process.env.NODE_ENV !== "production"; + async function findFiles(basePath, predicate, options = {}) { predicate = predicate ?? @@ -75,6 +77,11 @@ export async function compileSass(worker, path, options) { return worker.exec("compileSass", [path, options]); } +export async function compileSassDebug(worker) { + const result = await compileSass(worker, "resources/styles/debug.scss", {}); + return `${result.css}\n`; +} + export async function compileSassAll(worker) { const limitFn = pLimit(4); const sourceDir = "src"; @@ -94,10 +101,7 @@ export async function compileSassAll(worker) { .filter(isDesignSystemFile) .map((path) => ph.join(sourceDir, path)); - const procs = [ - compileSass(worker, "resources/styles/main-default.scss", {}), - compileSass(worker, "resources/styles/debug.scss", {}), - ]; + const procs = [compileSass(worker, "resources/styles/main-default.scss", {})]; for (let path of [...dsFiles, ...appFiles]) { const proc = limitFn(() => compileSass(worker, path, { modules: true })); @@ -176,7 +180,7 @@ async function renderTemplate(path, context = {}, partials = {}) { context = Object.assign({}, context, { ts: ts, - isDebug: process.env.NODE_ENV !== "production", + isDebug, }); return mustache.render(content, context, partials); @@ -401,6 +405,11 @@ export async function compileStyles() { await fs.mkdir("./resources/public/css", { recursive: true }); await fs.writeFile("./resources/public/css/main.css", result); + if (isDebug) { + let debugCSS = await compileSassDebug(worker); + await fs.writeFile("./resources/public/css/debug.css", debugCSS); + } + const end = process.hrtime(start); log.info("done: compile styles", `(${ppt(end)})`); worker.terminate();