Open source website builder and Webflow alternative. Webstudio is an advanced visual builder that connects to any headless CMS, supports all CSS properties, and can be hosted anywhere, including with us.
TypeScript accessibilityalternativecloudflarecloudflare-workersdesignfreefrontendopen-sourceradix-uireactremixweb-developmentwebflowwebsite-builderwebsite-developmentwebsiteswebstudio
import { mkdirSync, readFileSync, writeFileSync } from "node:fs";
import type { StyleValue } from "@webstudio-is/css-engine";
import { parseCss } from "../src/parse-css";
const css = readFileSync("./src/html.css", "utf8");
const { styles: parsed } = parseCss(css, new Map());
const result: [string, StyleValue][] = [];
for (const styleDecl of parsed) {
result.push([`${styleDecl.selector}:${styleDecl.property}`, styleDecl.value]);
}
let code = "";
code += `import type { StyleValue } from "@webstudio-is/css-engine";\n\n`;
const type = "Map<string, StyleValue>";
code += `export const html: ${type} = new Map(${JSON.stringify(result)})`;
mkdirSync("./src/__generated__", { recursive: true });
writeFileSync("./src/__generated__/html.ts", code);