swaf/src/frontend/TypeScriptPreCompiler.ts
Alice Gaudon 6aa37eb9e4 Add two step pre-compile/compile asset processing
Reorganize views into new "assets" folder structure
Turn locals into a store so locals don't have to be passed through files that don't need them
Some fixes to previous commit (esm) 82ab0b963c
Remove afs in favor of fs.promises (renamed afs.exists to Utils.doesFileExist
Rename Utils.readdirRecursively to Utils.listFilesRecursively
2021-05-04 17:14:32 +02:00

19 lines
671 B
TypeScript

import child_process from "child_process";
import {logger} from "../Logger.js";
import CopyAssetPreCompiler from "./CopyAssetPreCompiler.js";
export default class TypeScriptPreCompiler extends CopyAssetPreCompiler {
public constructor(
targetDir: string,
additionalFallbackAssetPaths: string[] = [],
) {
super(targetDir, 'ts', 'ts', additionalFallbackAssetPaths, false, 'ts-source');
this.onPreCompile(async _watch => {
logger.info('Building ts assets...');
await child_process.execSync(`yarn tsc -b tsconfig.frontend.json`, {stdio: [process.stdin, process.stdout, process.stderr]});
});
}
}