@@ -10,6 +10,7 @@ const CssMinimizerPlugin = require('css-minimizer-webpack-plugin');
1010module . exports  =  async  ( env ,  argv )  =>  { 
1111    const  isProduction  =  argv . mode  ===  'production' 
1212    const  isWatch  =  argv . watch  ===  true ; 
13+     let  isWatching  =  false 
1314
1415    const  config  =  { 
1516        // Path to your entry point. From this file Webpack will begin his work 
@@ -126,7 +127,6 @@ module.exports = async (env, argv) => {
126127    if  ( ! isProduction )  { 
127128        config . plugins . push ( { 
128129            apply : ( compiler )  =>  { 
129-                 // console.log('Webpack build is complete in development mode!'); 
130130                symlink ( './dist' ,  '../dist' ,  'dir' ) 
131131                symlink ( './node_modules/@cocreate/pwa/src/service-worker.js' ,  '../service-worker.js' ,  'file' ) 
132132                symlink ( './node_modules/@cocreate/pwa/src/manifest.webmanifest' ,  '../manifest.webmanifest' ,  'file' ) 
@@ -136,7 +136,20 @@ module.exports = async (env, argv) => {
136136    } 
137137
138138    if  ( isWatch )  { 
139-         upload ( __dirname ,  [ '../' ,  '-w' ] ) 
139+         config . plugins . push ( { 
140+             apply : ( compiler )  =>  { 
141+                 // Hook into the "emit" event, which occurs after the compilation is complete 
142+                 compiler . hooks . emit . tapAsync ( 'watchFiles' ,  ( compilation ,  callback )  =>  { 
143+                     if  ( ! isWatching )  { 
144+                         isWatching  =  true 
145+                         upload ( __dirname ,  [ '../' ,  '-w' ] ) 
146+                     } 
147+                     // Don't forget to call the callback function to signal completion 
148+                     callback ( ) ; 
149+                 } ) ; 
150+             } 
151+         } ) 
152+         // upload(__dirname, ['../', '-w']) 
140153    } 
141154
142155    return  config ; 
0 commit comments