-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbake.ts
60 lines (47 loc) · 1 KB
/
bake.ts
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
51
52
53
54
55
56
57
import fs from 'fs';
// remove dev css before syncing files
try {
fs.rmdirSync('./dist/', {recursive:true})
}
catch {
console.log("WARN: rm dist files failed");
}
try {
fs.mkdirSync('./dist/static', {recursive: true})
}
catch {
console.log("WARN: mkdir dist files failed");
}
try {
await Bun.build({
entrypoints: ['./src/server_prod.ts'],
outdir: './dist',
//minify: true,
format: "esm"
});
fs.renameSync('./dist/server_prod.js', './dist/_worker.js');
}
catch {
console.log("ERROR: production build failed");
}
// remove dev css before syncing files
try {
fs.rmSync('./static/main.css')
}
catch {
console.log("WARN: rm static/main.css file failed");
}
// copy contents from ./static to ./dist/static
try {
fs.cpSync('./static', './dist/static', {recursive: true});
}
catch {
console.log("WARN: copy static files failed");
}
// copy favicon to root
try {
fs.cpSync('./static/favicon.ico', './dist/favicon.ico');
}
catch {
console.log("WARN: copy favicon failed");
}