From d191931932b9293ce1be44ed08a1e69b9fcc1e25 Mon Sep 17 00:00:00 2001 From: f0x Date: Wed, 8 Jun 2022 23:00:02 +0200 Subject: [PATCH] fix bundler script paths --- web/source/frontend/index.js | 4 ++++ web/source/index.js | 4 ++++ web/source/lib/split-css.js | 10 +++++++--- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/web/source/frontend/index.js b/web/source/frontend/index.js index c6578860d..5a892e7f4 100644 --- a/web/source/frontend/index.js +++ b/web/source/frontend/index.js @@ -17,3 +17,7 @@ */ "use strict"; + + +// WARNING: currently dependencies get deduplicated with factor-bundle, but +// our frontend templates don't load the common bundle.js since it contains React etc \ No newline at end of file diff --git a/web/source/index.js b/web/source/index.js index 42808c44d..33fea3709 100644 --- a/web/source/index.js +++ b/web/source/index.js @@ -75,6 +75,10 @@ fs.readdirSync(path.join(__dirname, "./css")).forEach((file) => { entryFiles.push(path.join(__dirname, "./css", file)); }); +if (!fs.existsSync(out())){ + fs.mkdirSync(out(), { recursive: true }); +} + const server = budoExpress({ port: 8081, host: "localhost", diff --git a/web/source/lib/split-css.js b/web/source/lib/split-css.js index d15479c88..fb8694095 100644 --- a/web/source/lib/split-css.js +++ b/web/source/lib/split-css.js @@ -49,6 +49,8 @@ module.exports = function splitCSS() { } } + const cssDir = path.join(__dirname, "../css"); + stream.split("\n").forEach((line) => { if (line.startsWith("/* from")) { let found = fromRegex.exec(line); @@ -56,10 +58,12 @@ module.exports = function splitCSS() { write(); let parts = path.parse(found[1]); - if (parts.dir == "css") { + if (path.relative(cssDir, path.join(process.cwd(), parts.dir)) == "") { input = parts.base; } else { - input = found[1].replace(/\//g, "-"); + // prefix filename with path + let relative = path.relative(path.join(__dirname, "../"), path.join(process.cwd(), found[1])); + input = relative.replace(/\//g, "-"); } } } else { @@ -69,4 +73,4 @@ module.exports = function splitCSS() { write(); } }); -} +};