fix: build clean (#3351)

This commit is contained in:
jack zhang 2024-01-09 15:56:53 +08:00 committed by GitHub
parent effff269dc
commit 849096aafa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -127,14 +127,22 @@ const pluginPrefix = (
const target_dir = 'dist';
export function deleteJsFiles(cwd: string, log: PkgLog) {
log('delete babel js files');
const jsFiles = fg.globSync(['**/*', '!**/*.d.ts', '!node_modules'], {
export function deleteServerFiles(cwd: string, log: PkgLog) {
log('delete server files');
const files = fg.globSync(['*'], {
cwd: path.join(cwd, target_dir),
absolute: true,
deep: 1,
onlyFiles: true,
});
jsFiles.forEach((item) => {
fs.unlinkSync(item);
const dirs = fg.globSync(['*', '!client', '!node_modules'], {
cwd: path.join(cwd, target_dir),
absolute: true,
deep: 1,
onlyDirectories: true,
});
[...files, ...dirs].forEach((item) => {
fs.removeSync(item);
});
}
@ -255,6 +263,8 @@ export async function buildPluginServer(cwd: string, userConfig: UserConfig, sou
log('%s will not be processed, only be copied to the dist directory.', chalk.yellow(otherExts.join(',')));
}
deleteServerFiles(cwd, log);
await tsupBuild(userConfig.modifyTsupConfig({
entry: serverFiles,
splitting: false,