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
feat: add support for kirby serve w/ HMR plugin (#18)
* feat: add support for `kirby serve` w/ HMR plugin
* feat: allow HMR refresh, abort only on HMR reload
* feat: rename module entry to _index.mjs
makes it clearer that module entries are an internal, dev-only feature
* docs: update examples to include serve script
* feat: reload on PHP change in serve mode
* feat: live-reload via CLI arg, CLI help, refactor
* fix: only call server.close() if still listening
* fix: set server.origin to serve assets in dev mode
depends on vuejs/vue#12732
* fix: always pass array to vite-full-reload-plugin
ElMassimo/vite-plugin-full-reload#9
* feat: specify port via cli instead of kirbyup conf
* refactor: update reload-plugin, remove workaround
* feat: make sure index.dev.mjs is gone after build
* feat: set index.dev.mjs location with --out-dir
* docs: update README for serve command
* docs: capitalize "panel"
* refactor: inline getViteConfig() type
* fix: only handle SIGINT, implemented like vite
Copy file name to clipboardExpand all lines: README.md
+34-21Lines changed: 34 additions & 21 deletions
Original file line number
Diff line number
Diff line change
@@ -8,7 +8,7 @@ The fastest and leanest way to bundle your Kirby Panel plugins. No configuration
8
8
9
9
- 🍂 Lightweight, robust and tested
10
10
- ⚡️ Fast compilation with Vite/esbuild
11
-
-🔍 Watch mode
11
+
-🔄 Hot Module Replacement and Watch mode
12
12
-\*️⃣ `kirbyup.import` to [auto-import blocks & fields](#auto-import-blocks-and-fields)
13
13
- 🎒 [PostCSS support](#postcss)
14
14
- 🧭 [Path resolve aliases](#path-resolve-aliases)
@@ -36,7 +36,7 @@ If you want to use kirbyup right away, there is no need to install it. Simply ca
36
36
```json
37
37
{
38
38
"scripts": {
39
-
"dev": "npx -y kirbyup src/index.js --watch",
39
+
"dev": "npx -y kirbyup serve src/index.js",
40
40
"build": "npx -y kirbyup src/index.js"
41
41
}
42
42
}
@@ -55,7 +55,7 @@ Example package configuration:
55
55
```json
56
56
{
57
57
"scripts": {
58
-
"dev": "kirbyup src/index.js --watch",
58
+
"dev": "kirbyup serve src/index.js",
59
59
"build": "kirbyup src/index.js"
60
60
},
61
61
"devDependencies": {
@@ -70,31 +70,21 @@ Global installation is supported as well, but not recommended.
70
70
71
71
### Development
72
72
73
-
Rebuild the Panel plugin on any file changes:
73
+
Start a development server for the Panel plugin:
74
74
75
75
```bash
76
-
kirbyup src/index.js --watch
76
+
kirbyup serve src/index.js
77
77
```
78
78
79
-
You can also specify the directories to be watched. By default, if no path is specified, kirbyup watches the directory specified by the input file (`src` for the example above).
80
-
81
-
```bash
82
-
kirbyup src/index.js --watch src
83
-
```
84
-
85
-
You can specify more than a single directory:
86
-
87
-
```bash
88
-
kirbyup src/index.js --watch src --watch libs
89
-
```
79
+
This creates `./index.dev.mjs`, telling Kirby to load the development version of the plugin from the dev server started by `kirbyup serve`, enhanced by features like hot module replacement and auto-reload.
90
80
91
81
### Production
92
82
93
83
```bash
94
84
kirbyup src/index.js
95
85
```
96
86
97
-
The final panel plugin will be bundled, minified, and written into the current directory as `./index.js`.
87
+
The final panel plugin will be bundled, minified, and written into the current directory as `./index.js` and `./index.css`.
98
88
99
89
## Built-in Features
100
90
@@ -222,15 +212,38 @@ For a complete list of options, take a look at the [Vite configuration options](
222
212
223
213
## Options
224
214
225
-
> Inspect all available options with `kirbyup --help`.
215
+
> Inspect all available options with `kirbyup --help` and `kirbyup serve --help`.
216
+
217
+
### `kirbyup <input>`
226
218
227
-
### `--out-dir`
219
+
#####`--out-dir <dir>`
228
220
229
221
The output directory to save the processed code into. Defaults to the current working directory.
230
222
231
-
### `--watch`
223
+
##### `--watch [path]`
224
+
225
+
Enables watch mode. If no path is specified, kirbyup watches the folder of the input file. Repeat `--watch` for multiple paths.
226
+
227
+
### `kirbyup serve <input>`
228
+
229
+
##### `--port <port>`
230
+
231
+
The port for the development server to run on. Defaults to `5177`.
232
+
233
+
##### `--out-dir <dir>`
234
+
235
+
The output directory where the plugin file read by Kirby is saved. Defaults to the project root.
236
+
237
+
##### `--watch <path>`
238
+
239
+
Specifies additional files that should be watched for changes, with changes causing the page to reload. Repeat `--watch` for multiple paths.
240
+
241
+
> 💡 By default, kirbyup will watch all PHP files (`./**/*.php`) in the plugin directory and reload the page if it detects changes. Using `--watch` to set your own path overrides this setting, so you need to add the PHP glob explicitly if you want to keep the behavior: `--watch ./my/files/* --watch ./**/*.php`
242
+
243
+
##### `--no-watch`
244
+
245
+
Disables the default behavior of watching all PHP files for changes.
232
246
233
-
Sets the watch mode. If no path is specified, kirbyup watches the folder of the input file. Repeat `--watch` for multiple paths.
0 commit comments