# sad.ovh build system design goals: 1. rewrite and generate custom HTML/TS/JS/whatever.. 2. allow for variables and other important features in buildsystem->html 3. plugins, this ties together the top two 4. HMR and HTML/CSS reloading (in the Dev plugin) 5. Rewriteable file renaming 6. Every plugin runs on the same set of files, and can rename and reinject multiple times Psudeo-code build.ts ```ts class Plugin { .. whatever's needed to support the plugin system .. } if(.. not exist dist ..) .. make dist .. const plugins: Plugin[] = []; .. dynamically load plugins into plugins .. const srcFiles: File[] = [] .. get files into file .. export function build () { for(const file of srcFiles) { const plugins = plugins.filter(z=>z.rewriteTriggers(file.type)); if(plugins.length == 0) continue; for (const plugin of plugins) { let filename = file.name + "." + file.type; let newFilename = path.join("dist", file.name + "." + plugin.renameTo || file.type); fs.writeFileSync(newFilename, plugin.rewriteFile(fs.readFileSync(filename), filename)) } } } build(); ``` Psudeo-code plugins ```ts class DevPlugin extends Plugin { rewriteTriggers: ["html"] renameTo: undefined longLasting: false; .. websocket server .. constructor(.. options from argv of the main executable..) { .. ran on start of main index.ts executable .. .. this would be long lasting, so leave if not using --dev .. .. use a method on the server that rebuilds if required .. .. Would run a web server too .. } rewriteFile(file: string, filePath: string) { return file.replace("", ``) } } ``` ```ts class TSCompiler extends Plugin { rewriteTriggers: ["ts"] renameTo: "js" rewriteFile(file: string, filePath: string) { // use SWC or TS or esbuild, whatever } } ``` ```ts class MarkdownMetadataGenerator extends Plugin { rewriteTriggers: ["md"] renameTo: "json" rewriteFile(file: string, filePath: string) { return marked.parse(file); } } ``` ```ts class MarkdownCompiler extends Plugin { rewriteTriggers: ["md"] renameTo: "html" rewriteFile(file: string, filePath: string) { return marked.parse(file); } } ```