feat(includeFiles): support {from, to} object form for custom serve paths

includeFiles now accepts string | {from, to} entries. The object form
allows specifying a custom serve path (e.g. ./html/index.html -> index.html)
for base64ts bundled content.
This commit is contained in:
2026-02-24 17:02:46 +00:00
parent 801cab9001
commit 12c5655251
4 changed files with 32 additions and 9 deletions

View File

@@ -22,6 +22,20 @@ export class Base64TsOutput {
});
}
/**
* Add a file with a custom serve path
*/
public async addFileWithServePath(fromPath: string, servePath: string): Promise<void> {
const absolutePath = plugins.smartpath.transform.toAbsolute(fromPath, this.cwd) as string;
const fileExists = await plugins.fs.file(absolutePath).exists();
if (!fileExists) {
console.log(`File does not exist: ${absolutePath}`);
return;
}
const content = await plugins.fs.file(absolutePath).read();
this.addFile(servePath, content);
}
/**
* Add files matching a glob pattern
*/