Skip to content

Commit 2c69c96

Browse files
林全昌林全昌
authored andcommitted
chore: 优化部分代码
1 parent 7c33e3e commit 2c69c96

1 file changed

Lines changed: 1 addition & 21 deletions

File tree

packages/preset-built-in/tsup.config.ts

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,6 @@
1-
import { copyFileSync, mkdirSync, readdirSync } from 'node:fs';
2-
import { dirname, join } from 'node:path';
31
import { defineConfig } from 'tsup';
2+
import { copyTplFiles } from '../../scripts/shared.mjs';
43

5-
function copyTplFiles(srcDir: string, dstDir: string) {
6-
function walk(currentSrc: string, currentDst: string) {
7-
readdirSync(currentSrc, { withFileTypes: true }).forEach((dirent) => {
8-
const srcPath = join(currentSrc, dirent.name);
9-
const dstPath = join(currentDst, dirent.name);
10-
11-
if (dirent.isDirectory()) {
12-
walk(srcPath, dstPath);
13-
}
14-
else if (dirent.isFile() && dirent.name.endsWith('.tpl')) {
15-
mkdirSync(dirname(dstPath), { recursive: true });
16-
copyFileSync(srcPath, dstPath);
17-
console.log(`Copied: ${srcPath} -> ${dstPath}`);
18-
}
19-
});
20-
}
21-
walk(srcDir, dstDir);
22-
}
234
export default defineConfig({
245
entry: [
256
'src/index.ts',
@@ -57,7 +38,6 @@ export default defineConfig({
5738
dts: false,
5839
shims: true,
5940
format: ['esm'],
60-
outExtension: () => ({ js: '.mjs' }),
6141
onSuccess: () => {
6242
copyTplFiles('src', 'dist');
6343
},

0 commit comments

Comments
 (0)