1
1
/**
2
- * Copyright (c) 2018 -present, https://github.com/devloco
2
+ * Copyright (c) 2020 -present, https://github.com/devloco
3
3
*
4
4
* This source code is licensed under the MIT license found in the
5
5
* LICENSE file in the root directory of this source tree.
@@ -45,7 +45,7 @@ FileWatcherPlugin.prototype.apply = function (compiler) {
45
45
const touchFile = options . touchFile ;
46
46
const forceBuild = function ( touchFileName ) {
47
47
// -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.
49
49
touch ( "-c" , touchFileName ) ;
50
50
} ;
51
51
@@ -57,89 +57,84 @@ FileWatcherPlugin.prototype.apply = function (compiler) {
57
57
followSymlinks : options . followSymlinks || true ,
58
58
cwd : options . cwd || "." ,
59
59
disableGlobbing : options . disableGlobbing || false ,
60
- usePolling : options . usePolling || true ,
60
+ usePolling : options . usePolling || false ,
61
61
interval : options . interval || 100 ,
62
62
binaryInterval : options . binaryInterval || 300 ,
63
63
alwaysStat : options . alwaysStat || false ,
64
64
depth : options . depth || 99 ,
65
65
awaitWriteFinish : {
66
66
stabilityThreshold : options . stabilityThreshold || 250 ,
67
- pollInterval : options . pollInterval || 100
67
+ pollInterval : options . pollInterval || 100 ,
68
68
} ,
69
69
70
70
ignorePermissionErrors : options . ignorePermissionErrors || false ,
71
- atomic : options . atomic || true
71
+ atomic : options . atomic || true ,
72
72
} ) ;
73
73
74
74
watcher
75
75
. on (
76
76
"add" ,
77
77
options . 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
+ }
82
82
)
83
83
. on (
84
84
"change" ,
85
85
options . 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
+ }
95
90
)
96
91
. on (
97
92
"unlink" ,
98
93
options . 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
+ }
103
98
) ;
104
99
105
100
watcher
106
101
. on (
107
102
"addDir" ,
108
103
options . 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
+ }
113
108
)
114
109
. on (
115
110
"unlinkDir" ,
116
111
options . 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
+ }
121
116
)
122
117
. on (
123
118
"error" ,
124
119
options . 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
+ }
129
124
)
130
125
. on (
131
126
"ready" ,
132
127
options . 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
+ }
136
131
)
137
132
. on (
138
133
"raw" ,
139
134
options . onRawCallback ||
140
- function ( event , path , details ) {
141
- return null ;
142
- }
135
+ function ( event , path , details ) {
136
+ return null ;
137
+ }
143
138
) ;
144
139
} ) ;
145
140
} ;
0 commit comments