-
Notifications
You must be signed in to change notification settings - Fork 115
/
build.js
64 lines (57 loc) · 1.43 KB
/
build.js
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
58
59
60
61
62
63
64
const { ncp } = require('ncp')
const fs = require('fs')
const path = require('path')
const dest = path.resolve('./dist/')
// 移除包含 exports 的第二行
function simpleBrowserify(dir) {
fs.readFile(path.resolve(dest, dir), { encoding: 'utf-8' }, function(
err,
data
) {
if (err) {
console.error(err)
return
}
const lines = data.split('\n')
lines.splice(1, 1)
fs.writeFile(
path.resolve(dest, dir),
lines.join('\n'),
{ encoding: 'utf-8' },
() => {}
)
})
}
// Copy files
function copy(from, to = from, callback = () => {}) {
ncp(path.resolve('./', from), path.resolve(dest, to), err => {
if (err) console.error(err)
else callback()
})
}
function copyA(from, parent = 'bin', callback = () => {}) {
copy(from, parent + '/' + from, callback)
}
function copyDesktopCreatorFonts() {
// 桌布生成工具的字体
fs.copyFile(
'./assets/manager/fonts/SourceHanSansCN-Light.otf',
'./dist/bin/tool/desktopCreator/SourceHanSansCN-Light.otf',
err => {
if (err) console.error(err)
}
)
fs.copyFile(
'./assets/manager/fonts/SourceHanSansCN-Normal.otf',
'./dist/bin/tool/desktopCreator/SourceHanSansCN-Normal.otf',
err => {
if (err) console.error(err)
}
)
}
copy('assets', '')
copy('i18n')
copyA('resourcepack')
copyA('extension')
copyA('tool', 'bin', copyDesktopCreatorFonts)
simpleBrowserify('windows/sandbox-preload.js')