feat(website): add content structure files

This commit is contained in:
Alexander Navarro 2024-12-26 13:18:50 -03:00
parent 9c6d935069
commit 7af58fe829
35 changed files with 214 additions and 18 deletions

View file

@ -1,11 +1,30 @@
import type { BuildConfig, BunPlugin, PluginBuilder } from "bun";
import { parseArgs } from "node:util";
import { readdir, rm } from "node:fs/promises";
import { join } from "node:path";
import type { FileImporter } from "sass";
import { HTMLComponents } from "@mini-strap/components";
const outdir = "./static";
const { values } = parseArgs({
args: Bun.argv,
options: {
filter: {
type: "string",
short: "f",
default: "all",
},
output: {
type: "string",
short: "o",
default: "static",
},
},
strict: true,
allowPositionals: true,
});
const outdir = values.output ?? "./static";
const nodeModuleImporter: FileImporter<"async"> = {
findFileUrl(url) {
@ -35,8 +54,12 @@ const sassPlugin: BunPlugin = {
},
};
const assets: BuildConfig[] = [
{
const assets: BuildConfig[] = [];
const filter = values.filter ?? "all";
if (["all", "sass"].includes(filter)) {
assets.push({
entrypoints: ["./sass/style.scss"],
outdir: `${outdir}/css`,
naming: "[name].css",
@ -46,17 +69,21 @@ const assets: BuildConfig[] = [
// On by default in Bun v1.2+
html: true,
experimentalCss: true,
},
});
}
{
if (["all", "js", "ts"].includes(filter)) {
assets.push({
entrypoints: ["./js/index.ts"],
outdir: `${outdir}/js`,
target: "browser",
splitting: true,
minify: true,
},
});
}
{
if (["all", "html"].includes(filter)) {
assets.push({
entrypoints: Object.values(HTMLComponents),
outdir: "./templates/ext-components",
target: "browser",
@ -69,8 +96,8 @@ const assets: BuildConfig[] = [
// On by default in Bun v1.2+
html: true,
experimentalCss: true,
},
];
});
}
const out = await Promise.all(
assets.map(async (item) => {