File tree 2 files changed +15
-3
lines changed
2 files changed +15
-3
lines changed Original file line number Diff line number Diff line change
1
+ import { exec } from 'node:child_process'
2
+ import { promisify } from 'node:util'
1
3
import { defineBuildConfig } from 'unbuild'
2
4
import builtins from 'builtin-modules'
3
5
6
+ const execAsync = promisify ( exec )
7
+
4
8
export default defineBuildConfig ( {
5
9
outDir : './dist' ,
6
10
sourcemap : true ,
@@ -39,4 +43,14 @@ export default defineBuildConfig({
39
43
// by esbuild
40
44
inlineDependencies : true ,
41
45
} ,
46
+ hooks : {
47
+ 'build:before' : async ( ) => {
48
+ await execAsync ( 'rm -rf ./main.js' )
49
+ await execAsync ( 'rm -rf ./main.js.map' )
50
+ } ,
51
+ 'build:done' : async ( ) => {
52
+ await execAsync ( 'cp ./dist/main.js ./main.js' )
53
+ await execAsync ( 'cp ./dist/main.js.map ./main.js.map' )
54
+ } ,
55
+ } ,
42
56
} )
Original file line number Diff line number Diff line change 21
21
" dist"
22
22
],
23
23
"scripts" : {
24
- "cleanup" : " rm -rf ./main.js && rm -rf ./main.js.map" ,
25
- "build" : " unbuild && pnpm run cleanup && pnpm run copy" ,
26
- "copy" : " cp ./dist/main.js ./main.js && cp ./dist/main.js.map ./main.js.map" ,
24
+ "build" : " unbuild" ,
27
25
"lint" : " eslint --cache ."
28
26
},
29
27
"devDependencies" : {
You can’t perform that action at this time.
0 commit comments