@@ -67,39 +67,38 @@ export class DevupUIWebpackPlugin {
6767
6868 apply ( compiler : Compiler ) {
6969 // read devup.json
70- if ( existsSync ( this . options . devupPath ) ) {
70+ const existsDevup = existsSync ( this . options . devupPath )
71+ if ( existsDevup ) {
7172 try {
7273 this . writeDataFiles ( )
7374 } catch ( error ) {
7475 console . error ( error )
7576 }
7677
77- let lastModifiedTime : number | null = null
78-
7978 compiler . hooks . afterCompile . tap ( 'DevupUIWebpackPlugin' , ( compilation ) => {
8079 compilation . fileDependencies . add ( this . options . devupPath )
81- this . watch = true
8280 } )
83- compiler . hooks . watchRun . tapAsync (
84- 'DevupUIWebpackPlugin' ,
85- ( _ , callback ) => {
86- stat ( this . options . devupPath , ( err , stats ) => {
87- if ( err ) {
88- console . error ( `Error checking ${ this . options . devupPath } :` , err )
89- return callback ( )
90- }
81+ }
9182
92- const modifiedTime = stats . mtimeMs
93- if ( lastModifiedTime && lastModifiedTime !== modifiedTime ) {
94- this . writeDataFiles ( )
95- }
83+ let lastModifiedTime : number | null = null
84+ compiler . hooks . watchRun . tapAsync ( 'DevupUIWebpackPlugin' , ( _ , callback ) => {
85+ this . watch = true
86+ if ( existsDevup )
87+ stat ( this . options . devupPath , ( err , stats ) => {
88+ if ( err ) {
89+ console . error ( `Error checking ${ this . options . devupPath } :` , err )
90+ return callback ( )
91+ }
9692
97- lastModifiedTime = modifiedTime
98- callback ( )
99- } )
100- } ,
101- )
102- }
93+ const modifiedTime = stats . mtimeMs
94+ if ( lastModifiedTime && lastModifiedTime !== modifiedTime ) {
95+ this . writeDataFiles ( )
96+ }
97+
98+ lastModifiedTime = modifiedTime
99+ callback ( )
100+ } )
101+ } )
103102 // Create an empty CSS file
104103 if ( ! existsSync ( this . options . cssFile ) ) {
105104 writeFileSync ( this . options . cssFile , '' , { encoding : 'utf-8' } )
0 commit comments