File tree Expand file tree Collapse file tree 1 file changed +18
-0
lines changed
Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -9,10 +9,28 @@ const path = require('path')
99const chalk = require ( 'chalk' )
1010const webpack = require ( 'webpack' )
1111const config = require ( '../config' )
12+ const glob = require ( 'glob' )
13+ const fs = require ( 'fs' )
1214const webpackConfig = require ( './webpack.prod.conf' )
1315
1416const spinner = ora ( 'building for production...' )
1517spinner . start ( )
18+ const TO = path . join ( __dirname , '..' , 'dist' )
19+
20+ if ( fs . existsSync ( TO ) ) {
21+ let file = [ ]
22+ glob . sync ( `${ TO } /**` ) . forEach ( ( pathname ) => {
23+ file . push ( pathname )
24+ } )
25+ for ( let i = file . length - 1 ; i >= 0 ; i -- ) {
26+ if ( fs . statSync ( file [ i ] ) . isFile ( ) ) {
27+ fs . unlinkSync ( file [ i ] )
28+ } else {
29+ fs . rmdirSync ( file [ i ] )
30+ }
31+ }
32+ }
33+ fs . mkdirSync ( TO )
1634
1735rm ( path . join ( config . build . assetsRoot , config . build . assetsSubDirectory ) , err => {
1836 if ( err ) throw err
You can’t perform that action at this time.
0 commit comments