Skip to content

Commit 595914e

Browse files
authored
Merge pull request #343 from MagicMirrorOrg/develop
update doc
2 parents 873b879 + a826ede commit 595914e

File tree

5 files changed

+64
-32
lines changed

5 files changed

+64
-32
lines changed

configuration/introduction.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ The following properties can be configured, place them above the modules item:
5959
| `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. | [] |
6060
| `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"];` | [] |
6161
| `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` |
6263

6364
After the above options, you will then add modules. See
6465
[module configuration](/modules/configuration.md) for more information.
@@ -74,7 +75,7 @@ are:
7475
| ------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
7576
| MM_CONFIG_FILE | This specifies an alternate configuration file for the system. This is useful when running multiple mirrors on the same device. This does not work with the template option below. NOTE: this file **_MUST_** be located in a directory within the MagicMirror directory. Ideally, place any config file in the config subdirectory. |
7677
| MM_PORT | This specifies an alternate TCP/IP port, overriding "port" item within the config file. This is useful for testing to see if the product will run using another port. |
77-
| mmFetchTimeout | time in milliseconds for fetch timeout. default (30000) <br><br>this value can be used to adjust the nodejs fetch function timeout value (default 10 seconds) for all node_helper modules that use fetch() |
78+
| mmFetchTimeout | time in milliseconds for fetch timeout. default (30000) <br><br>this value can be used to adjust the nodejs fetch function timeout value for all node_helper modules that use fetch() |
7879

7980
#### Examples of use
8081

core-development/debugging.md

Lines changed: 42 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,18 +30,57 @@ Developer consoles in browsers and the Electron app (typically CTRL+SHIFT+I to
3030
toggle open/close) can be used to set client-side breakpoints, step through
3131
scripts and inspect variables.
3232

33+
## Watch Mode with Auto-Reload
34+
35+
For active development, MagicMirror² provides a `server:watch` script that
36+
automatically restarts the server and reloads connected browsers when files
37+
change:
38+
39+
```sh
40+
node --run server:watch
41+
```
42+
43+
This mode monitors files specified in your `config.js` under the `watchTargets`
44+
property:
45+
46+
```js
47+
let config = {
48+
watchTargets: [
49+
"config/config.js",
50+
"css/custom.css",
51+
"modules/MMM-MyModule/MMM-MyModule.js",
52+
"modules/MMM-MyModule/node_helper.js",
53+
],
54+
// ... rest of config
55+
};
56+
```
57+
58+
When any monitored file changes:
59+
60+
1. The server automatically restarts
61+
2. Waits for the port to become available
62+
3. Sends a reload notification to all connected browsers via Socket.io
63+
4. Browsers automatically refresh to show the changes
64+
65+
This creates a seamless development experience where you can edit code, save,
66+
and see the results within seconds without manual restarts.
67+
68+
**Note:** If `watchTargets` is empty or undefined, the watcher starts but
69+
monitors nothing.
70+
3371
## Logging
3472

3573
While there are no log files produced by the server, info is reported in two
3674
different places:
3775

38-
- The console when running from `npm run start` or `npm run server`.
76+
- The console when running from `node --run start`, `node --run server`, or
77+
`node --run server:watch`.
3978
- This is separated into two streams, `console.log()` is output as the
4079
`stdout` stream, and
4180
- `console.error()` is output as the `stderr` stream.
4281
- These can be redirected to files when starting the server. `>` will redirect
4382
`stdout`, and `2>` will redirect `stderr`. `2>&1` will combine both streams:
44-
`npm run start > out.log 2>&1`
83+
`node --run start > out.log 2>&1`
4584
- The browser's developer console (typically CTRL+SHIFT+I to toggle open/close)
4685
will have output from scripts that run on the browser.
4786

@@ -113,5 +152,5 @@ script, such as `start:dev`:
113152
Or when running from the command line (Linux example):
114153

115154
```sh
116-
TZ=Europe/Madrid npm run start:dev
155+
TZ=Europe/Madrid node --run start:dev
117156
```

cspell.config.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@
6464
"Trixie",
6565
"trunc",
6666
"tympanus",
67-
"ukmetoffice",
6867
"ukmetofficedatahub",
6968
"UKMO",
7069
"updatenotification",

modules/updatenotification.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ The following properties can be configured:
3131
| `updates` | Array of updates modules commands. <br> **Default value:** `[]` (see bellow) |
3232
| `updateTimeout` | Maximum Update duration before cancel it. <br> **Default Value:** `120000` (2 minutes) |
3333
| `updateAutorestart` | Restart automatically MagicMirror² after update is done. <br> **Default Value:** `false` |
34-
| `useModulesFromConfig` | If `false`, iterate over the modules directory instead of using the modules defined in `config.js`. <br> **Default Value:** `true` |
34+
| `useModulesFromConfig` | If `false`, iterate over the modules directory instead of using the modules defined in `config.js`. <br> **Default Value:** `true` |
3535

3636
### `updates` Array
3737

0 commit comments

Comments
 (0)