Update watcher function. Add .css files to the rebuild pipeline

This commit is contained in:
Benjamin Toby 2026-03-21 14:58:41 +01:00
parent 13bd8bb851
commit 632c70fc90
3 changed files with 15 additions and 7 deletions

View File

@ -30,10 +30,11 @@ export default function watcher() {
} }
return; return;
} }
if (!filename.match(target_files_match)) { const is_file_of_interest = Boolean(filename.match(target_files_match));
if (!is_file_of_interest) {
return; return;
} }
if (!filename.match(/^src\/pages\//)) if (!filename.match(/^src\/pages\/|\.css$/))
return; return;
if (filename.match(/\/(--|\()/)) if (filename.match(/\/(--|\()/))
return; return;
@ -41,8 +42,9 @@ export default function watcher() {
return; return;
const fullPath = path.join(ROOT_DIR, filename); const fullPath = path.join(ROOT_DIR, filename);
const action = existsSync(fullPath) ? "created" : "deleted"; const action = existsSync(fullPath) ? "created" : "deleted";
const type = filename.match(/\.css$/) ? "Sylesheet" : "Page";
await fullRebuild({ await fullRebuild({
msg: `Page ${action}: ${filename}. Rebuilding ...`, msg: `${type} ${action}: ${filename}. Rebuilding ...`,
}); });
}); });
global.PAGES_SRC_WATCHER = pages_src_watcher; global.PAGES_SRC_WATCHER = pages_src_watcher;

View File

@ -27,7 +27,7 @@
], ],
"scripts": { "scripts": {
"dev": "tsc --watch", "dev": "tsc --watch",
"git:push": "tsc --noEmit && tsc && git add . && git commit -m 'Update README.md' && git push", "git:push": "tsc --noEmit && tsc && git add . && git commit -m 'Update watcher function. Add .css files to the rebuild pipeline' && git push",
"compile": "bun build ./src/commands/index.ts --compile --outfile bin/bunext", "compile": "bun build ./src/commands/index.ts --compile --outfile bin/bunext",
"build": "tsc", "build": "tsc",
"test": "bun test --max-concurrency=1" "test": "bun test --max-concurrency=1"

View File

@ -15,6 +15,7 @@ export default function watcher() {
}, },
async (event, filename) => { async (event, filename) => {
if (!filename) return; if (!filename) return;
const excluded_match = const excluded_match =
/node_modules\/|^public\/|^\.bunext\/|^\.git\/|^dist\/|bun\.lockb$/; /node_modules\/|^public\/|^\.bunext\/|^\.git\/|^dist\/|bun\.lockb$/;
@ -38,20 +39,25 @@ export default function watcher() {
return; return;
} }
if (!filename.match(target_files_match)) { const is_file_of_interest = Boolean(
filename.match(target_files_match),
);
if (!is_file_of_interest) {
return; return;
} }
if (!filename.match(/^src\/pages\//)) return; if (!filename.match(/^src\/pages\/|\.css$/)) return;
if (filename.match(/\/(--|\()/)) return; if (filename.match(/\/(--|\()/)) return;
if (global.RECOMPILING) return; if (global.RECOMPILING) return;
const fullPath = path.join(ROOT_DIR, filename); const fullPath = path.join(ROOT_DIR, filename);
const action = existsSync(fullPath) ? "created" : "deleted"; const action = existsSync(fullPath) ? "created" : "deleted";
const type = filename.match(/\.css$/) ? "Sylesheet" : "Page";
await fullRebuild({ await fullRebuild({
msg: `Page ${action}: ${filename}. Rebuilding ...`, msg: `${type} ${action}: ${filename}. Rebuilding ...`,
}); });
}, },
); );