-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.js
55 lines (42 loc) · 1.65 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
const fs = require('fs')
const w3viewBuilder = require('w3view/builder/builder.js')
const path = require('path')
const webpack = require('webpack')
const wpconf = require(path.resolve(__dirname, 'webpack.config.js'))
const TMP_DIR = './src/web/js/tmp'
console.time('total time')
const copyFiles = [
['css/style.css', 'css/style.css'],
['index.m.html', 'index.html']
]
try {
fs.mkdirSync(path.resolve(__dirname, TMP_DIR), { recursive: true })
fs.rmSync(path.resolve(__dirname, './dist'), { recursive: true })
} catch (e) { }
w3viewBuilder(
path.resolve(__dirname, './src/web/w3v/screen.w3v.html'),
'w3v',
(built) => {
fs.writeFileSync(path.resolve(__dirname, TMP_DIR, 'screen.w3v.js'),
'import W3View from \'w3view\' \n\nexport default ' + built)
console.log('screen.w3v.js built')
console.log('build modules')
webpack(wpconf, (err) => {
if (err) {
console.error(err)
return
}
fs.rmSync(path.resolve(__dirname, TMP_DIR), { recursive: true })
copyFiles.forEach((fname) => {
try {
console.log(path.resolve(__dirname, 'dist/web', path.dirname(fname[1])))
fs.mkdirSync(path.resolve(__dirname, 'dist/web', path.dirname(fname[1])), { recursive: true })
} catch (e) { }
fs.copyFileSync(path.resolve(__dirname, 'src/web', fname[0]), path.resolve(__dirname, 'dist/web', fname[1]))
console.log(fname[0], 'copyed')
})
console.info('build success')
console.timeEnd('total time')
})
}
)