a reactive (signals based) hypermedia web framework (wip)
stormlightlabs.github.io/volt/
hypermedia
frontend
signals
1import { echo } from "$console/echo.js";
2import { buildLibrary, copyBuildArtifacts, findBuildArtifacts } from "$utils/build.js";
3import path from "node:path";
4
5export type BuildCommandOptions = { minify?: boolean; css?: boolean };
6
7/**
8 * Build command implementation.
9 *
10 * Builds the Volt.js library and copies the build artifacts to the specified
11 * output directory. Supports optional minification and CSS inclusion.
12 */
13export async function buildCommand(outDir: string = ".", options: BuildCommandOptions = {}): Promise<void> {
14 const minify = options.minify !== false;
15 const includeCss = options.css !== false;
16
17 const resolvedOutDir = path.resolve(process.cwd(), outDir);
18
19 echo.title("\nBuilding Volt.js library...\n");
20 echo.info("Building library...");
21 await buildLibrary();
22
23 echo.info("Finding build artifacts...");
24 const artifacts = await findBuildArtifacts();
25
26 echo.info(`Copying to ${resolvedOutDir}...`);
27 await copyBuildArtifacts(artifacts, { outDir: resolvedOutDir, minify, includeCss });
28
29 echo.success("\nBuild completed successfully!\n");
30
31 if (minify) {
32 echo.info(`Output: ${outDir}${outDir.endsWith("/") ? "" : "/"}volt.min.js`);
33 if (includeCss) {
34 echo.info(` ${outDir}${outDir.endsWith("/") ? "" : "/"}volt.min.css\n`);
35 }
36 } else {
37 echo.info(`Output: ${outDir}${outDir.endsWith("/") ? "" : "/"}volt.js`);
38 if (includeCss) {
39 echo.info(` ${outDir}${outDir.endsWith("/") ? "" : "/"}volt.css\n`);
40 }
41 }
42}