File tree 3 files changed +23
-3
lines changed
3 files changed +23
-3
lines changed Original file line number Diff line number Diff line change @@ -2,7 +2,7 @@ import { ProgressPlugin } from 'webpack';
2
2
import env from 'std-env' ;
3
3
import prettyTime from 'pretty-time' ;
4
4
5
- import { startCase } from './utils' ;
5
+ import { startCase , shortenPath } from './utils' ;
6
6
7
7
import * as reporters from './reporters' ; // eslint-disable-line import/no-namespace
8
8
import { parseRequest , hook } from './utils/webpack' ;
@@ -149,6 +149,15 @@ export default class WebpackBarPlugin extends ProgressPlugin {
149
149
this . callReporters ( 'start' ) ;
150
150
} ) ;
151
151
152
+ // Watch compilation has been invalidated.
153
+ hook ( compiler , 'invalid' , ( fileName , changeTime ) => {
154
+ this . callReporters ( 'change' , {
155
+ path : fileName ,
156
+ shortPath : shortenPath ( fileName ) ,
157
+ time : changeTime ,
158
+ } ) ;
159
+ } ) ;
160
+
152
161
// Compilation has completed
153
162
hook ( compiler , 'done' , ( stats ) => {
154
163
const time = prettyTime ( process . hrtime ( this . state . start ) , 2 ) ;
Original file line number Diff line number Diff line change @@ -5,6 +5,10 @@ export default class SimpleReporter {
5
5
consola . info ( `Compiling ${ context . state . name } ` ) ;
6
6
}
7
7
8
+ change ( context , { shortPath } ) {
9
+ consola . info ( `${ shortPath } changed.` , `Rebuilding ${ context . state . name } ` ) ;
10
+ }
11
+
8
12
done ( context ) {
9
13
const { hasError, message, name } = context . state ;
10
14
consola [ hasError ? 'error' : 'success' ] ( `${ name } : ${ message } ` ) ;
Original file line number Diff line number Diff line change
1
+ import { sep } from 'path' ;
2
+
1
3
export function first ( arr ) {
2
4
return arr [ 0 ] ;
3
5
}
@@ -27,10 +29,15 @@ export function removeBefore(delimiter, str) {
27
29
return last ( str . split ( delimiter ) ) || '' ;
28
30
}
29
31
30
- export const range = ( len ) => {
32
+ export function range ( len ) {
31
33
const arr = [ ] ;
32
34
for ( let i = 0 ; i < len ; i ++ ) {
33
35
arr . push ( i ) ;
34
36
}
35
37
return arr ;
36
- } ;
38
+ }
39
+
40
+ export function shortenPath ( path = '' ) {
41
+ const cwd = process . cwd ( ) + sep ;
42
+ return path . replace ( cwd , '' ) ;
43
+ }
You can’t perform that action at this time.
0 commit comments