Skip to content

Commit 75f620d

Browse files
authoredJan 26, 2023
Improve basic development experience (Koenkk#1844)
* feat: Add nvm support * feat: Add support for single device include when working in devmode * feat: Add ability to change dev port * feat: Wording fix * feat: Bump node version recommendation to 18
1 parent 59a62ea commit 75f620d

File tree

3 files changed

+37
-2
lines changed

3 files changed

+37
-2
lines changed
 

‎.nvmrc

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
18

‎README.md

+30-2
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,12 @@ Docgen includes some scripts to help testing the page.
4848

4949
## VuePress
5050

51-
Use Node.js 16 for building VuePress (other versions like Node.js 18 are not supported)
51+
Use Node.js 18 for building VuePress (other versions are not officially supported).
5252

5353
```bash
54+
# Switch to node 18 (for nvm or nvm-compatible tool users)
55+
nvm use
56+
5457
# Install dependencies
5558
npm ci
5659
```
@@ -74,13 +77,38 @@ npm run dev
7477
The `dev`-Mode **excludes** the huge amount device-pages which slows down the build process drastically.
7578
If you are interested in the device-pages you could include them by using the `npm run dev:devices` npm-run script.
7679

80+
#### Include specific device
81+
82+
When running in `dev`-Mode, you can also specify a device (but this device only) which you would like to include in the build process.
83+
Useful when working on improving notes of just one device.
84+
`INCLUDE_DEVICE` variable should be supplied with device's filename (see [`/docs/devices`](/docs/devices/) folder), without the `.md.` extension.
85+
86+
```bash
87+
# Run vuepress in dev mode with specific device included
88+
npx cross-env INCLUDE_DEVICE=<DEVICE_FILE_NAME> npm run dev
89+
90+
# Example for TS011F_plug_1
91+
npx cross-env INCLUDE_DEVICE=TS011F_plug_1 npm run dev
92+
```
93+
94+
#### Change development port
95+
96+
You can change development server port when the default one (8080) is taken on your system.
97+
98+
```bash
99+
# Run vuepress in dev mode on specified port
100+
npx cross-env DEV_PORT=<PORT_NUMBER> npm run dev
101+
102+
# Example for port no 15080
103+
npx cross-env DEV_PORT=15080 npm run dev
104+
```
77105

78106
## Docker
79107

80108
You can also just use a docker-image include Node.js.
81109

82110
```bash
83-
$ docker run --rm -v $PWD:/app -u $UID -ti node:16 bash
111+
$ docker run --rm -v $PWD:/app -u $UID -ti node:18-slim bash
84112
node@87e1438ef553:/$ cd /app
85113
node@87e1438ef553:/app$ npm ci
86114
node@87e1438ef553:/app$ npm run dev

‎vuepress.config.ts

+6
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,14 @@ const pagePatterns = ['**/*.md', '!.vuepress', '!node_modules'];
1818
if (process.env.EXCLUDE_DEVICES) {
1919
pagePatterns.push('!devices');
2020
}
21+
if (process.env.INCLUDE_DEVICE) {
22+
pagePatterns.push(`devices/${process.env.INCLUDE_DEVICE}.md`);
23+
}
24+
25+
const devServerPort = (process.env.DEV_PORT ? parseInt(process.env.DEV_PORT, 10) : undefined);
2126

2227
const conf = defineUserConfig({
28+
port: devServerPort,
2329
base: getBase(),
2430
title: 'Zigbee2MQTT' + ( isDevelop ? ' develop' : '' ),
2531
description: 'Zigbee to MQTT bridge, get rid of your proprietary Zigbee bridges',

0 commit comments

Comments
 (0)
Please sign in to comment.