2018-08-22 15:14:49 +08:00
|
|
|
import ora from 'ora'
|
|
|
|
import webpack from 'webpack'
|
2018-08-22 16:01:51 +08:00
|
|
|
import config from './webpack.config'
|
2018-08-22 15:14:49 +08:00
|
|
|
|
|
|
|
const spinner = ora('Building …')
|
|
|
|
|
|
|
|
export default new Promise((resolve, reject) => {
|
|
|
|
spinner.start()
|
|
|
|
|
|
|
|
webpack(config, (error, stats) => {
|
|
|
|
if (error) {
|
|
|
|
return reject(error)
|
|
|
|
}
|
|
|
|
|
|
|
|
if (stats.hasErrors()) {
|
|
|
|
process.stdout.write(stats.toString() + "\n");
|
|
|
|
return reject(new Error('Build failed with errors.'))
|
|
|
|
}
|
|
|
|
|
|
|
|
return resolve('Build complete.')
|
|
|
|
})
|
|
|
|
})
|
|
|
|
.then(success => spinner.succeed(success))
|
|
|
|
.catch(error => spinner.fail(error))
|