Skip to content

Commit d31f9ac

Browse files
committedJul 10, 2024··
chore: better unbuild hook for copy and removal
Signed-off-by: Neko Ayaka <[email protected]>
1 parent 95ae906 commit d31f9ac

File tree

3 files changed

+18
-8
lines changed

3 files changed

+18
-8
lines changed
 

‎build.config.ts

+14-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
1+
import { exec } from 'node:child_process'
2+
import { promisify } from 'node:util'
13
import { defineBuildConfig } from 'unbuild'
24
import builtins from 'builtin-modules'
35

6+
const execAsync = promisify(exec)
7+
48
export default defineBuildConfig({
59
outDir: './dist',
610
sourcemap: true,
@@ -20,11 +24,6 @@ export default defineBuildConfig({
2024
'@lezer/common',
2125
'@lezer/highlight',
2226
'@lezer/lr',
23-
// UnoCSS
24-
'@iconify/utils/lib/loader/fs',
25-
'@iconify/utils/lib/loader/install-pkg',
26-
'@iconify/utils/lib/loader/node-loader',
27-
'@iconify/utils/lib/loader/node-loaders',
2827
// Builtins
2928
...builtins,
3029
],
@@ -44,4 +43,14 @@ export default defineBuildConfig({
4443
// by esbuild
4544
inlineDependencies: true,
4645
},
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+
},
4756
})

‎cspell.config.yaml

+3
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,12 @@ dictionaries: []
55
words:
66
- antfu
77
- codemirror
8+
- collab
9+
- lezer
810
- nolebase
911
- Nólëbase
1012
- ofetch
13+
- unocss
1114
- vueuse
1215
ignoreWords: []
1316
import: []

‎package.json

+1-3
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,7 @@
2626
"dist"
2727
],
2828
"scripts": {
29-
"cleanup": "rm -rf ./main.js && rm -rf ./main.js.map",
30-
"build": "unbuild && pnpm run cleanup && pnpm run copy",
31-
"copy": "cp ./dist/main.js ./main.js && cp ./dist/main.js.map ./main.js.map",
29+
"build": "unbuild",
3230
"lint": "eslint --cache ."
3331
},
3432
"devDependencies": {

0 commit comments

Comments
 (0)
Please sign in to comment.