mirror of
https://github.com/Theodor-Springmann-Stiftung/lenz-web.git
synced 2025-12-16 14:35:32 +00:00
air update +version bump
This commit is contained in:
41
views/scripts/build.mjs
Normal file
41
views/scripts/build.mjs
Normal file
@@ -0,0 +1,41 @@
|
||||
import { build, context } from "esbuild";
|
||||
import { fileURLToPath } from "node:url";
|
||||
import path from "node:path";
|
||||
|
||||
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
||||
const projectRoot = path.resolve(__dirname, "..");
|
||||
|
||||
const args = new Set(process.argv.slice(2));
|
||||
const isWatch = args.has("--watch");
|
||||
const shouldMinify = args.has("--minify") || args.has("--mode=production");
|
||||
|
||||
const entryFile = path.join(projectRoot, "transform", "main.js");
|
||||
const outFile = path.join(projectRoot, "assets", "scripts.js");
|
||||
|
||||
const buildOptions = {
|
||||
entryPoints: [entryFile],
|
||||
outfile: outFile,
|
||||
bundle: true,
|
||||
format: "esm",
|
||||
target: ["es2020"],
|
||||
platform: "browser",
|
||||
sourcemap: true,
|
||||
minify: shouldMinify,
|
||||
logLevel: "info",
|
||||
};
|
||||
|
||||
async function run() {
|
||||
if (isWatch) {
|
||||
const ctx = await context(buildOptions);
|
||||
await ctx.watch();
|
||||
console.log("[esbuild] watching for changes...");
|
||||
} else {
|
||||
await build(buildOptions);
|
||||
console.log("[esbuild] build completed");
|
||||
}
|
||||
}
|
||||
|
||||
run().catch((err) => {
|
||||
console.error(err);
|
||||
process.exit(1);
|
||||
});
|
||||
46
views/scripts/dev.mjs
Normal file
46
views/scripts/dev.mjs
Normal file
@@ -0,0 +1,46 @@
|
||||
import { spawn } from "node:child_process";
|
||||
import { fileURLToPath } from "node:url";
|
||||
import path from "node:path";
|
||||
|
||||
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
||||
const projectRoot = path.resolve(__dirname, "..");
|
||||
|
||||
const processes = [];
|
||||
|
||||
function resolveBin(name) {
|
||||
const ext = process.platform === "win32" ? ".cmd" : "";
|
||||
return path.join(projectRoot, "node_modules", ".bin", name + ext);
|
||||
}
|
||||
|
||||
function run(command, args) {
|
||||
const child = spawn(command, args, {
|
||||
cwd: projectRoot,
|
||||
stdio: "inherit",
|
||||
});
|
||||
processes.push(child);
|
||||
child.on("exit", (code) => {
|
||||
if (code !== 0) {
|
||||
console.error(`${command} exited with code ${code}`);
|
||||
process.exitCode = code;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
run("node", [path.join("scripts", "build.mjs"), "--watch"]);
|
||||
run(resolveBin("postcss"), ["transform/site.css", "-o", "assets/style.css", "--watch"]);
|
||||
|
||||
function shutdown() {
|
||||
for (const child of processes) {
|
||||
child.kill("SIGINT");
|
||||
}
|
||||
}
|
||||
|
||||
process.on("SIGINT", () => {
|
||||
shutdown();
|
||||
process.exit();
|
||||
});
|
||||
|
||||
process.on("SIGTERM", () => {
|
||||
shutdown();
|
||||
process.exit();
|
||||
});
|
||||
Reference in New Issue
Block a user