11const webpack = require ( 'webpack' ) ;
22const logger = require ( './logger' ) ;
3- const { cyanBright, greenBright } = require ( 'colorette' ) ;
43const { CompilerOutput } = require ( './CompilerOutput' ) ;
5- const readline = require ( 'readline' ) ;
64
75class Compiler {
86 constructor ( ) {
@@ -18,36 +16,15 @@ class Compiler {
1816
1917 compilation . hooks . beforeRun . tap ( 'webpackProgress' , ( ) => {
2018 if ( outputOptions . progress ) {
21- process . stdout . write ( '\n' ) ;
22- const defaultProgressPluginHandler = ( percent , msg ) => {
23- percent = Math . floor ( percent * 100 ) ;
24- readline . clearLine ( process . stdout , 0 ) ;
25- readline . cursorTo ( process . stdout , 0 , null ) ;
26- if ( percent !== undefined ) {
27- process . stdout . write ( ' (' ) ;
28- for ( let i = 0 ; i <= 100 ; i += 10 ) {
29- if ( i <= percent ) {
30- process . stdout . write ( greenBright ( '#' ) ) ;
31- } else {
32- process . stdout . write ( '#' ) ;
33- }
34- }
35- process . stdout . write ( `) ${ percent } % : ` ) ;
36- process . stdout . write ( `${ cyanBright ( msg ) } ` ) ;
37- if ( percent === 100 ) {
38- process . stdout . write ( `${ cyanBright ( 'Compilation completed\n' ) } ` ) ;
39- }
40- }
41- } ;
4219 if ( ! progressPluginExists ) {
43- new ProgressPlugin ( defaultProgressPluginHandler ) . apply ( compilation ) ;
20+ new ProgressPlugin ( ) . apply ( compilation ) ;
4421 } else {
4522 if ( ! progressPluginExists . handler ) {
4623 options . plugins = options . plugins . filter ( ( e ) => e !== progressPluginExists ) ;
4724 Object . keys ( progressPluginExists ) . map ( ( opt ) => {
4825 ProgressPlugin . defaultOptions [ opt ] = progressPluginExists [ opt ] ;
4926 } ) ;
50- new ProgressPlugin ( defaultProgressPluginHandler ) . apply ( compilation ) ;
27+ new ProgressPlugin ( ) . apply ( compilation ) ;
5128 } else {
5229 progressPluginExists . apply ( compilation ) ;
5330 }
0 commit comments