virmator 7.0.0 → 7.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -36,16 +36,10 @@ function alwaysReloadPlugin(config = {}) {
|
|
|
36
36
|
name: 'alwaysReloadPlugin',
|
|
37
37
|
apply: 'serve',
|
|
38
38
|
config: () => ({ server: { watch: { disableGlobbing: false } } }),
|
|
39
|
-
configureServer({ watcher, ws, config: { logger } }) {
|
|
40
|
-
const {
|
|
39
|
+
configureServer({ watcher, ws, config: { logger, publicDir = '', root = process.cwd() } }) {
|
|
40
|
+
const { inclusions = [], exclusions = [] } = config;
|
|
41
41
|
let callingAlready = false;
|
|
42
|
-
|
|
43
|
-
const reloadCallback = (path) => {
|
|
44
|
-
if (!loggedAlready) {
|
|
45
|
-
loggedAlready = true;
|
|
46
|
-
// log watched stuff so that we can make sure it's not watching too much
|
|
47
|
-
// console.info({watched: watcher.getWatched()});
|
|
48
|
-
}
|
|
42
|
+
function reloadCallback(path) {
|
|
49
43
|
// prevent duplicate calls cause the watcher is very eager to call callbacks multiple times in a row
|
|
50
44
|
if (!callingAlready) {
|
|
51
45
|
callingAlready = true;
|
|
@@ -53,28 +47,39 @@ function alwaysReloadPlugin(config = {}) {
|
|
|
53
47
|
type: 'full-reload',
|
|
54
48
|
path: '*',
|
|
55
49
|
});
|
|
56
|
-
logger.info(`${node_js_1.logColors.success}page reload ${node_js_1.logColors.faint}${(0, path_1.relative)(
|
|
50
|
+
logger.info(`${node_js_1.logColors.success}page reload ${node_js_1.logColors.faint}${(0, path_1.relative)(process.cwd(), path)}${node_js_1.logColors.reset}`, {
|
|
51
|
+
clear: true,
|
|
52
|
+
timestamp: true,
|
|
53
|
+
});
|
|
57
54
|
/**
|
|
58
|
-
* Debounce reloads calls so that they don't get spammed. If you're
|
|
59
|
-
* faster than this, then what the heck are you doing
|
|
55
|
+
* Debounce reloads calls so that they don't get spammed. If you're actually
|
|
56
|
+
* intentionally saving faster than this, then what the heck are you doing?
|
|
60
57
|
*/
|
|
61
58
|
setTimeout(() => {
|
|
62
59
|
callingAlready = false;
|
|
63
60
|
}, 100);
|
|
64
61
|
}
|
|
65
|
-
}
|
|
62
|
+
}
|
|
63
|
+
watcher.add(root);
|
|
66
64
|
if (exclusions.length) {
|
|
67
65
|
watcher.unwatch(mapToActualPaths(exclusions));
|
|
68
|
-
// ignore macOS file system metadata stuff
|
|
69
66
|
}
|
|
67
|
+
// ignore macOS file system metadata stuff
|
|
70
68
|
watcher.unwatch('./**/.DS_Store');
|
|
71
69
|
if (inclusions.length) {
|
|
72
|
-
watcher.add(inclusions);
|
|
70
|
+
watcher.add(mapToActualPaths(inclusions));
|
|
71
|
+
}
|
|
72
|
+
if (publicDir) {
|
|
73
|
+
watcher.add(publicDir);
|
|
73
74
|
}
|
|
75
|
+
watcher.removeAllListeners();
|
|
74
76
|
if (!watcher.listeners('change').includes(reloadCallback)) {
|
|
75
77
|
watcher.on('change', reloadCallback);
|
|
76
78
|
watcher.on('add', reloadCallback);
|
|
79
|
+
watcher.on('unlink', reloadCallback);
|
|
77
80
|
}
|
|
81
|
+
// // for debugging. Note that this isn't actually reliable, test the actual reloads.
|
|
82
|
+
// console.info({watched: watcher.getWatched()});
|
|
78
83
|
},
|
|
79
84
|
};
|
|
80
85
|
}
|