You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: configuration/introduction.md
+1Lines changed: 1 addition & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -59,6 +59,7 @@ The following properties can be configured, place them above the modules item:
59
59
|`electronOptions`| An optional array of Electron (browser) options. This allows configuration of e.g. the browser screen size and position (example: `electronOptions: { fullscreen: false, width: 800, height: 600 }`). Kiosk mode can be enabled by setting `kiosk: true`, `autoHideMenuBar: false` and `fullscreen: false`. More options can be found [here](https://github.com/electron/electron/blob/master/docs/api/browser-window.md). This will most likely be used in advanced installations, below. |[]|
60
60
|`electronSwitches`| An optional array of Electron switches. This allows configuration of electron app itself. <br> This properties will not affect the `serveronly` mode. Usually normal `MM` users don't need this property, but if you are a hard-core hacker, you might need this to handle Electron itself over `MagicMirror` provides. More options can be found [here](https://www.electronjs.org/docs/latest/api/command-line-switches) (Not all available switches are described there.)<br>example:`electronSwitches:["enable-transparent-visuals", "disable-gpu"];`|[]|
61
61
|`customCss`| The path of the `custom.css` stylesheet. The default is `css/custom.css`. |`css/custom.css`|
62
+
|`watchTargets`| An optional array of file paths to monitor when using `node --run server:watch`. When any of these files change, the server automatically restarts and connected browsers reload. Particularly useful when frequently modifying `config.js`, `custom.css`, or module files during development or setup. Example: `watchTargets: ["config/config.js", "css/custom.css", "modules/MMM-MyModule/MMM-MyModule.js"]`. See [Development Mode](/core-development/debugging.html#development-mode-with-auto-reload) for more details. |`undefined`|
62
63
63
64
After the above options, you will then add modules. See
64
65
[module configuration](/modules/configuration.md) for more information.
Copy file name to clipboardExpand all lines: core-development/debugging.md
+35-3Lines changed: 35 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -30,18 +30,50 @@ Developer consoles in browsers and the Electron app (typically CTRL+SHIFT+I to
30
30
toggle open/close) can be used to set client-side breakpoints, step through
31
31
scripts and inspect variables.
32
32
33
+
## Watch Mode with Auto-Reload
34
+
35
+
For active development, MagicMirror² provides a `server:watch` script that automatically restarts the server and reloads connected browsers when files change:
36
+
37
+
```sh
38
+
node --run server:watch
39
+
```
40
+
41
+
This mode monitors files specified in your `config.js` under the `watchTargets` property:
42
+
43
+
```js
44
+
let config = {
45
+
watchTargets: [
46
+
"config/config.js",
47
+
"css/custom.css",
48
+
"modules/MMM-MyModule/MMM-MyModule.js",
49
+
"modules/MMM-MyModule/node_helper.js"
50
+
],
51
+
// ... rest of config
52
+
};
53
+
```
54
+
55
+
When any monitored file changes:
56
+
1. The server automatically restarts
57
+
2. Waits for the port to become available
58
+
3. Sends a reload notification to all connected browsers via Socket.io
59
+
4. Browsers automatically refresh to show the changes
60
+
61
+
This creates a seamless development experience where you can edit code, save, and see the results within seconds without manual restarts.
62
+
63
+
**Note:** If `watchTargets` is empty or undefined, the watcher starts but monitors nothing.
64
+
33
65
## Logging
34
66
35
67
While there are no log files produced by the server, info is reported in two
36
68
different places:
37
69
38
-
- The console when running from `npm run start`or `npm run server`.
70
+
- The console when running from `node --run start`, `node --run server`, or `node --run server:watch`.
39
71
- This is separated into two streams, `console.log()` is output as the
40
72
`stdout` stream, and
41
73
-`console.error()` is output as the `stderr` stream.
42
74
- These can be redirected to files when starting the server. `>` will redirect
43
75
`stdout`, and `2>` will redirect `stderr`. `2>&1` will combine both streams:
44
-
`npm run start > out.log 2>&1`
76
+
`node --run start > out.log 2>&1`
45
77
- The browser's developer console (typically CTRL+SHIFT+I to toggle open/close)
46
78
will have output from scripts that run on the browser.
47
79
@@ -113,5 +145,5 @@ script, such as `start:dev`:
113
145
Or when running from the command line (Linux example):
0 commit comments