1 | "use strict";
|
2 | var __importDefault = (this && this.__importDefault) || function (mod) {
|
3 | return (mod && mod.__esModule) ? mod : { "default": mod };
|
4 | };
|
5 | Object.defineProperty(exports, "__esModule", { value: true });
|
6 | exports.watchPlugin = void 0;
|
7 | const debounce_1 = __importDefault(require("debounce"));
|
8 | function watchPlugin() {
|
9 | return {
|
10 | name: 'watch',
|
11 | injectWebSocket: true,
|
12 | serverStart({ fileWatcher, webSockets }) {
|
13 | if (!webSockets) {
|
14 | throw new Error('Cannot use watch mode when web sockets are disabled.');
|
15 | }
|
16 | function onFileChanged() {
|
17 | webSockets.sendImport('data:text/javascript,window.location.reload()');
|
18 | }
|
19 | const onChange = (0, debounce_1.default)(onFileChanged, 100);
|
20 | fileWatcher.addListener('change', onChange);
|
21 | fileWatcher.addListener('unlink', onChange);
|
22 | },
|
23 | };
|
24 | }
|
25 | exports.watchPlugin = watchPlugin;
|
26 |
|
\ | No newline at end of file |