-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbuild.config.ts
More file actions
50 lines (42 loc) · 1.16 KB
/
build.config.ts
File metadata and controls
50 lines (42 loc) · 1.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import { defineBuildConfig } from 'unbuild'
import fs from 'fs'
import path from 'path'
const copyFolderRecursive = (src: string, dest: string) => {
if (!fs.existsSync(dest)) {
fs.mkdirSync(dest, { recursive: true });
}
const entries = fs.readdirSync(src, { withFileTypes: true });
for (const entry of entries) {
const srcPath = path.join(src, entry.name);
const destPath = path.join(dest, entry.name);
if (entry.isDirectory()) {
copyFolderRecursive(srcPath, destPath);
} else {
fs.copyFileSync(srcPath, destPath);
}
}
};
export default defineBuildConfig({
entries: [
"src/bin.ts"
],
clean: true,
declaration: true, // Generate .d.ts files
outDir: 'dist',
rollup: {
emitCJS: true,
inlineDependencies: false,
},
hooks: {
'build:done': () => {
const srcDir = path.join(__dirname, 'src/assets');
const destDir = path.join(__dirname, 'dist/assets');
if (fs.existsSync(srcDir)) {
copyFolderRecursive(srcDir, destDir);
console.log('Copied src/assets to dist/assets');
} else {
console.warn('Source directory not found: src/assets');
}
},
},
})