@@ -13,28 +13,32 @@ var webpackConfig = require('./webpack.prod.conf')
1313var spinner = ora ( 'building for production...' )
1414spinner . start ( )
1515
16- rm ( path . join ( config . build . assetsRoot , config . build . assetsSubDirectory ) , err => {
17- if ( err ) throw err
18- webpack ( webpackConfig , function ( err , stats ) {
19- spinner . stop ( )
20- if ( err ) throw err
21- process . stdout . write ( stats . toString ( {
22- colors : true ,
23- modules : false ,
24- children : false ,
25- chunks : false ,
26- chunkModules : false
27- } ) + '\n\n' )
16+ module . exports = ( ) => new Promise ( ( resolve , reject ) => {
17+ rm ( path . join ( config . build . assetsRoot , config . build . assetsSubDirectory ) , err => {
18+ if ( err ) reject ( err )
19+ webpack ( webpackConfig , function ( err , stats ) {
20+ spinner . stop ( )
21+ if ( err ) reject ( err )
22+ process . stdout . write ( stats . toString ( {
23+ colors : true ,
24+ modules : false ,
25+ children : false ,
26+ chunks : false ,
27+ chunkModules : false
28+ } ) + '\n\n' )
2829
29- if ( stats . hasErrors ( ) ) {
30- console . log ( chalk . red ( ' Build failed with errors.\n' ) )
31- process . exit ( 1 )
32- }
30+ if ( stats . hasErrors ( ) ) {
31+ console . log ( chalk . red ( ' Build failed with errors.\n' ) )
32+ process . exit ( 1 )
33+ }
3334
34- console . log ( chalk . cyan ( ' Build complete.\n' ) )
35- console . log ( chalk . yellow (
36- ' Tip: built files are meant to be served over an HTTP server.\n' +
37- ' Opening index.html over file:// won\'t work.\n'
38- ) )
35+ console . log ( chalk . cyan ( ' Build complete.\n' ) )
36+ console . log ( chalk . yellow (
37+ ' Tip: built files are meant to be served over an HTTP server.\n' +
38+ ' Opening index.html over file:// won\'t work.\n'
39+ ) )
40+
41+ resolve ( )
42+ } )
3943 } )
4044} )
0 commit comments