2026-03-21 17:51:25 +00:00
|
|
|
import esbuild from "esbuild";
|
|
|
|
|
import vue from "esbuild-plugin-vue3";
|
2026-03-21 19:14:51 +00:00
|
|
|
import { sassPlugin } from "esbuild-sass-plugin";
|
2026-03-21 17:51:25 +00:00
|
|
|
|
|
|
|
|
const args = process.argv.slice(2);
|
|
|
|
|
const watch = args.includes("--watch");
|
|
|
|
|
const minify = args.includes("--minify");
|
|
|
|
|
|
2026-03-21 21:44:10 +00:00
|
|
|
// Plugin to show build status
|
|
|
|
|
const buildStatusPlugin = {
|
|
|
|
|
name: "build-status",
|
|
|
|
|
setup(build) {
|
|
|
|
|
let buildStart;
|
|
|
|
|
|
|
|
|
|
build.onStart(() => {
|
|
|
|
|
buildStart = Date.now();
|
|
|
|
|
// Clear console and move cursor to top
|
|
|
|
|
console.clear();
|
|
|
|
|
console.log(
|
|
|
|
|
"\x1b[36m%s\x1b[0m",
|
|
|
|
|
`🔨 Building... [${new Date().toLocaleTimeString()}]`,
|
|
|
|
|
);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
build.onEnd((result) => {
|
|
|
|
|
const buildTime = Date.now() - buildStart;
|
|
|
|
|
if (result.errors.length > 0) {
|
|
|
|
|
console.log(
|
|
|
|
|
"\x1b[31m%s\x1b[0m",
|
|
|
|
|
`❌ Build failed (${buildTime}ms) [${new Date().toLocaleTimeString()}]`,
|
|
|
|
|
);
|
|
|
|
|
} else {
|
|
|
|
|
console.log(
|
|
|
|
|
"\x1b[32m%s\x1b[0m",
|
|
|
|
|
`✅ Build complete (${buildTime}ms) [${new Date().toLocaleTimeString()}]`,
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
console.log("\x1b[33m%s\x1b[0m", "\n👀 Watching for changes...");
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
|
2026-03-21 17:51:25 +00:00
|
|
|
const config = {
|
|
|
|
|
entryPoints: ["ts/main.ts"],
|
|
|
|
|
bundle: true,
|
|
|
|
|
format: "esm",
|
2026-03-21 19:14:51 +00:00
|
|
|
plugins: [
|
2026-03-21 21:44:10 +00:00
|
|
|
buildStatusPlugin, // Add this first
|
2026-03-21 19:14:51 +00:00
|
|
|
sassPlugin({
|
|
|
|
|
quietDeps: true,
|
2026-03-21 19:34:23 +00:00
|
|
|
silenceDeprecations: ["import"],
|
2026-03-21 19:14:51 +00:00
|
|
|
type: "css",
|
|
|
|
|
}),
|
|
|
|
|
vue(),
|
|
|
|
|
],
|
2026-03-21 17:51:25 +00:00
|
|
|
define: {
|
|
|
|
|
__VUE_OPTIONS_API__: "true",
|
|
|
|
|
__VUE_PROD_DEVTOOLS__: "false",
|
|
|
|
|
__VUE_PROD_HYDRATION_MISMATCH_DETAILS__: "false",
|
|
|
|
|
},
|
|
|
|
|
minify,
|
2026-03-21 18:13:40 +00:00
|
|
|
loader: {
|
|
|
|
|
".css": "css",
|
2026-03-21 19:34:23 +00:00
|
|
|
".woff": "file",
|
|
|
|
|
".woff2": "file",
|
|
|
|
|
".ttf": "file",
|
|
|
|
|
".eot": "file",
|
2026-03-21 18:13:40 +00:00
|
|
|
},
|
|
|
|
|
outdir: "static/gen",
|
|
|
|
|
outbase: "ts",
|
2026-03-21 19:34:23 +00:00
|
|
|
assetNames: "fonts/[name]",
|
2026-03-21 17:51:25 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
if (watch) {
|
|
|
|
|
const ctx = await esbuild.context(config);
|
|
|
|
|
await ctx.watch();
|
2026-03-21 21:44:10 +00:00
|
|
|
console.log("\x1b[33m%s\x1b[0m", "👀 Watching for changes...\n");
|
2026-03-21 17:51:25 +00:00
|
|
|
} else {
|
|
|
|
|
await esbuild.build(config);
|
|
|
|
|
}
|