add a lot more configuration options for more involved projects

This commit is contained in:
Soph :3 2025-01-11 15:46:07 +02:00
parent e68ad369e9
commit bae2bac25b
Signed by: sophie
GPG key ID: EDA5D222A0C270F2
2 changed files with 10 additions and 6 deletions

View file

@ -15,7 +15,7 @@ export default class DevPlugin extends Plugin {
server!: Server;
allConnections: ServerWebSocket<number>[] = [];
constructor(sssg: SSSG) {
constructor(sssg: SSSG, headers: Record<string, string>) {
super();
fs.watch(
@ -71,6 +71,7 @@ export default class DevPlugin extends Plugin {
"Pragma": "no-cache",
"Expires": "0",
"Content-Type": (mime.lookup(type) || "application/octet-stream") + "; charset=utf-8",
...headers
},
});
},

View file

@ -9,14 +9,16 @@ export default class TSCompiler extends Plugin {
rewriteTriggers = ["ts", "tsx", "jsx"];
renameTo = "js";
longLasting = false;
esbuildOptions: esbuild.BuildOptions;
minify = false;
constructor() {
constructor(minify: boolean, esbuildOptions: esbuild.BuildOptions = {}) {
super();
if (process.argv.includes("--prod")) {
this.minify = true;
}
this.minify = minify;
this.esbuildOptions = esbuildOptions;
}
async rewriteFile(file: string, filePath: string) {
let result;
try {
@ -38,6 +40,7 @@ export default class TSCompiler extends Plugin {
bundle: true,
outdir: "out",
minify: this.minify,
...this.esbuildOptions
});
} catch (e) {
console.error(e);
@ -51,7 +54,7 @@ export default class TSCompiler extends Plugin {
console.error(element);
});
} else {
const output = result.outputFiles[0].contents;
const output = result.outputFiles![0].contents;
return new TextDecoder().decode(output);
}
}