0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-02-15 19:48:22 -05:00

🐛 Fix debug css being included in prod builds

This commit is contained in:
Belén Albeza 2024-07-08 15:33:26 +02:00
parent 44a2a63fb8
commit fb6ebcd074

View file

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