11const webpack = require ( 'webpack' ) ;
22const logger = require ( './logger' ) ;
3+ const { cyanBright, greenBright } = require ( 'chalk' ) ;
34const { CompilerOutput } = require ( './CompilerOutput' ) ;
45
56class Compiler {
@@ -15,17 +16,26 @@ class Compiler {
1516
1617 compilation . hooks . beforeRun . tap ( 'webpackProgress' , ( ) => {
1718 if ( outputOptions . progress ) {
18- let tmpMsg ;
19+ process . stdout . write ( '\n' ) ;
1920 const defaultProgressPluginHandler = ( percent , msg ) => {
2021 percent = Math . floor ( percent * 100 ) ;
21- if ( percent === 100 ) {
22- msg = 'Compilation completed' ;
22+ process . stdout . clearLine ( ) ;
23+ process . stdout . cursorTo ( 0 ) ;
24+ if ( percent !== undefined ) {
25+ process . stdout . write ( ' (' ) ;
26+ for ( let i = 0 ; i <= 100 ; i += 10 ) {
27+ if ( i <= percent ) {
28+ process . stdout . write ( greenBright ( '#' ) ) ;
29+ } else {
30+ process . stdout . write ( '#' ) ;
31+ }
32+ }
33+ process . stdout . write ( `) ${ percent } % : ` ) ;
34+ process . stdout . write ( `${ cyanBright ( msg ) } ` ) ;
35+ if ( percent === 100 ) {
36+ process . stdout . write ( `${ cyanBright ( 'Complilation completed\n' ) } ` ) ;
37+ }
2338 }
24-
25- if ( msg && tmpMsg != msg ) {
26- logger . info ( percent + '% ' + msg ) ;
27- }
28- tmpMsg = msg ;
2939 } ;
3040 if ( ! progressPluginExists ) {
3141 new ProgressPlugin ( defaultProgressPluginHandler ) . apply ( compilation ) ;
0 commit comments