forked from quasarframework/quasar
-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
46 lines (34 loc) · 834 Bytes
/
index.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
const webpack = require('webpack')
const { log, warn } = require('../helpers/logger')
class BexRunner {
constructor () {
this.watcher = null
}
init () {}
async run (quasarConfFile) {
this.stop()
const compiler = webpack(quasarConfFile.webpackConf.main)
return new Promise(resolve => {
log(`Building background process...`)
this.watcher = compiler.watch({}, (err, stats) => {
if (err) {
console.log(err)
return
}
log(`Webpack built background process`)
if (stats.hasErrors()) {
warn(`BEX Background build failed with errors`)
return
}
resolve()
})
})
}
stop () {
if (this.watcher) {
this.watcher.close()
this.watcher = null
}
}
}
module.exports = new BexRunner()