fix bundler script paths

This commit is contained in:
f0x 2022-06-08 23:00:02 +02:00
commit d191931932
3 changed files with 15 additions and 3 deletions

View file

@ -17,3 +17,7 @@
*/ */
"use strict"; "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

View file

@ -75,6 +75,10 @@ fs.readdirSync(path.join(__dirname, "./css")).forEach((file) => {
entryFiles.push(path.join(__dirname, "./css", file)); entryFiles.push(path.join(__dirname, "./css", file));
}); });
if (!fs.existsSync(out())){
fs.mkdirSync(out(), { recursive: true });
}
const server = budoExpress({ const server = budoExpress({
port: 8081, port: 8081,
host: "localhost", host: "localhost",

View file

@ -49,6 +49,8 @@ module.exports = function splitCSS() {
} }
} }
const cssDir = path.join(__dirname, "../css");
stream.split("\n").forEach((line) => { stream.split("\n").forEach((line) => {
if (line.startsWith("/* from")) { if (line.startsWith("/* from")) {
let found = fromRegex.exec(line); let found = fromRegex.exec(line);
@ -56,10 +58,12 @@ module.exports = function splitCSS() {
write(); write();
let parts = path.parse(found[1]); let parts = path.parse(found[1]);
if (parts.dir == "css") { if (path.relative(cssDir, path.join(process.cwd(), parts.dir)) == "") {
input = parts.base; input = parts.base;
} else { } 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 { } else {
@ -69,4 +73,4 @@ module.exports = function splitCSS() {
write(); write();
} }
}); });
} };