UNPKG

481 BJavaScriptView Raw
1const webpack = require('webpack')
2const { print } = require('./stats')
3
4const cb = () => {}
5
6const compiler = (config, callback = cb) => {
7 return new Promise((res, rej) => {
8 const compiler = webpack(config)
9 compiler.run((err, stats) => {
10 if (err) {
11 console.log('打包出错')
12 console.log(err)
13 rej(err)
14 } else {
15 print(stats)
16 res()
17 }
18 })
19 compiler.plugin('done', callback)
20 })
21}
22
23module.exports = compiler