import fs from "fs";
import path from "path";
import { fileURLToPath } from "url";
const __dirname = path.dirname(fileURLToPath(import.meta.url));
const ROOT_DIR = path.resolve(__dirname, "..");
const ASSETS_DIR = path.resolve(ROOT_DIR, "assets");
const baseUrl = process.env.BASE_URL || "http://localhost:4444";
const components = ["calculator"];
for (const component of components) {
const jsFile = `${component}.js`;
const cssFile = `${component}.css`;
const htmlFile = `${component}.html`;
const html = `<!doctype html>
<html>
<head>
<script type="module" src="${baseUrl}/${jsFile}"></script>
<link rel="stylesheet" href="${baseUrl}/${cssFile}">
</head>
<body>
<div id="${component}-root"></div>
</body>
</html>
`;
const htmlPath = path.join(ASSETS_DIR, htmlFile);
fs.writeFileSync(htmlPath, html, { encoding: "utf8" });
console.log(`Generated ${htmlFile}`);
}
console.log("\nBuild complete! Assets ready in ./assets/");
console.log(`Using BASE_URL: ${baseUrl}`);