11/**
2- * Copyright (c)2018 -present, https://github.com/devloco
2+ * Copyright (c)2020 -present, https://github.com/devloco
33 *
44 * This source code is licensed under the MIT license found in the
55 * LICENSE file in the root directory of this source tree.
@@ -45,7 +45,7 @@ FileWatcherPlugin.prototype.apply = function (compiler) {
4545const touchFile = options . touchFile ;
4646const forceBuild = function ( touchFileName ) {
4747// -c to not create a file if one doesn't already exist.
48- // Remember this file needs to be watched by WebPack, thus it should already exist
48+ // Remember this file needs to be watched by WebPack, thus it should already exist.
4949touch ( "-c" , touchFileName ) ;
5050} ;
5151
@@ -57,89 +57,84 @@ FileWatcherPlugin.prototype.apply = function (compiler) {
5757followSymlinks :options . followSymlinks || true ,
5858cwd :options . cwd || "." ,
5959disableGlobbing :options . disableGlobbing || false ,
60- usePolling :options . usePolling || true ,
60+ usePolling :options . usePolling || false ,
6161interval :options . interval || 100 ,
6262binaryInterval :options . binaryInterval || 300 ,
6363alwaysStat :options . alwaysStat || false ,
6464depth :options . depth || 99 ,
6565awaitWriteFinish :{
6666stabilityThreshold :options . stabilityThreshold || 250 ,
67- pollInterval :options . pollInterval || 100
67+ pollInterval :options . pollInterval || 100 ,
6868} ,
6969
7070ignorePermissionErrors :options . ignorePermissionErrors || false ,
71- atomic :options . atomic || true
71+ atomic :options . atomic || true ,
7272} ) ;
7373
7474watcher
7575. on (
7676"add" ,
7777options . onAddCallback ||
78- function ( path ) {
79- //forceBuild(touchFile); // causes infinite loops for "add"
80- return null ;
81- }
78+ function ( path ) {
79+ //forceBuild(touchFile); // causes infinite loops for "add"
80+ return null ;
81+ }
8282)
8383. on (
8484"change" ,
8585options . onChangeCallback ||
86- function ( path ) {
87- // console.log(`\n\n Compilation Started after change of - ${path} \n\n`);
88- // compiler.run(function(err) {
89- // if (err) throw err;
90- // watcher.close();
91- // });
92- //console.log(`\n\n Compilation ended for change of - ${path} \n\n`);
93- forceBuild ( touchFile ) ;
94- }
86+ function ( path ) {
87+ console . log ( `\n\n FileWatcherPlugin CHANGE for:${ path } \n\n` ) ;
88+ forceBuild ( touchFile ) ;
89+ }
9590)
9691. on (
9792"unlink" ,
9893options . onUnlinkCallback ||
99- function ( path ) {
100- // console.log(`File ${path}has been removed `);
101- forceBuild ( touchFile ) ;
102- }
94+ function ( path ) {
95+ // console.log(`\n\n FileWatcherPlugin UNLINK for: ${path}\n\n `);
96+ forceBuild ( touchFile ) ;
97+ }
10398) ;
10499
105100watcher
106101. on (
107102"addDir" ,
108103options . onAddDirCallback ||
109- function ( path ) {
110- // console.log(`Directory ${path}has been added `);
111- forceBuild ( touchFile ) ;
112- }
104+ function ( path ) {
105+ // console.log(`\n\n FileWatcherPlugin ADDDIR for: ${path}\n\n `);
106+ forceBuild ( touchFile ) ;
107+ }
113108)
114109. on (
115110"unlinkDir" ,
116111options . unlinkDirCallback ||
117- function ( path ) {
118- // console.log(`Directory ${path}has been removed `);
119- forceBuild ( touchFile ) ;
120- }
112+ function ( path ) {
113+ // console.log(`\n\n FileWatcherPlugin UNLINKDIR for: ${path}\n\n `);
114+ forceBuild ( touchFile ) ;
115+ }
121116)
122117. on (
123118"error" ,
124119options . onErrorCallback ||
125- function ( error ) {
126- console . log ( `FileWatcherPlugin error:${ error } ` ) ;
127- return null ;
128- }
120+ function ( error ) {
121+ // console.log(`FileWatcherPlugin error: ${error}`);
122+ return null ;
123+ }
129124)
130125. on (
131126"ready" ,
132127options . onReadyCallback ||
133- function ( ) {
134- console . log ( "Watching for changes in the Public folder." ) ;
135- }
128+ function ( ) {
129+ console . log ( "Watching for changes in the Public folder." /*, watcher.getWatched()*/ ) ;
130+ }
136131)
137132. on (
138133"raw" ,
139134options . onRawCallback ||
140- function ( event , path , details ) {
141- return null ;
142- }
135+ function ( event , path , details ) {
136+ return null ;
137+ }
143138) ;
144139} ) ;
145140} ;