kirbyup 3.1.2 → 3.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,53 +1,43 @@
1
- # kirbyup
1
+ [![kirbyup](./docs/public/og.png)](https://kirbyup.getkirby.com)
2
2
 
3
- > [!TIP]
4
- > Take a look into Kirby's [pluginkit](https://github.com/getkirby/pluginkit/tree/4-panel) repository for an example setup.
3
+ # kirbyup
5
4
 
6
- The fastest and leanest way to bundle your Kirby Panel plugins. No configuration necessary.
5
+ [![npm version](https://img.shields.io/npm/v/kirbyup?color=a1b858&label=)](https://www.npmjs.com/package/kirbyup)
7
6
 
8
- ## Key Features
7
+ The official bundler for Kirby Panel plugins with zero-config usage and built-in HMR.
9
8
 
10
- - 🍂 Lightweight, robust and tested
11
- - ⚡️ Fast compilation with Vite/esbuild
12
- - 🔄 Hot module replacement and watch mode
13
- - \*️⃣ `kirbyup.import` to [auto-import blocks & fields](#auto-import-blocks-and-fields)
14
- - 🎒 [PostCSS support](#postcss)
15
- - 🧭 [Path resolve aliases](#path-resolve-aliases)
16
- - 🔌 [Env variables support](#env-variables)
17
- - 🦔 [Extendable configuration with `kirbyup.config.js`](#extendable-configuration-with-kirbyupconfigjs)
9
+ - [✨  Release Notes](https://github.com/johannschopplich/kirbyup/releases)
10
+ - [📖  Read the documentation](https://kirbyup.getkirby.com)
18
11
 
19
- ## Get Started Right Away
20
-
21
- … With one of the following Panel plugin kits:
12
+ ## Key Features
22
13
 
23
- - [`eslint`](./examples/eslint)
24
- - [`tailwindcss`](./examples/tailwindcss)
14
+ - 🔄 [Hot module replacement](https://kirbyup.getkirby.com/guide/getting-started.html#development)
15
+ - 🎒 PostCSS support
16
+ - 🧭 Add custom path aliases
17
+ - 🔌 Run actions based on environment variables
18
+ - 🦔 [Extends Vite with `kirbyup.config.js`](https://kirbyup.getkirby.com/guide/config-file)
25
19
 
26
- I highly recommend using one of these starters instead of [Kirby's default `pluginkit`](https://github.com/getkirby/pluginkit/tree/4-panel). They provide a better developer experience out of the box.
20
+ ## Setup
27
21
 
28
- ## Installation
22
+ > [!TIP]
23
+ > [📖 Read the documentation](https://kirbyup.getkirby.com)
29
24
 
30
- If you want to use kirbyup right away, there is no need to install it. Simply call it with `npx`:
25
+ ```bash
26
+ # pnpm
27
+ pnpm add -D kirbyup
31
28
 
32
- ```json
33
- {
34
- "scripts": {
35
- "dev": "npx -y kirbyup serve src/index.js",
36
- "build": "npx -y kirbyup src/index.js"
37
- }
38
- }
29
+ # npm
30
+ npm i -D kirbyup
39
31
  ```
40
32
 
41
- > [!NOTE]
42
- > If `npx` doesn't use the latest kirbyup version, although it is available, run `npx -y kirbyup@latest` instead or delete the `~/.npm/_npx` cache folder.
33
+ ## Basic Usage
43
34
 
44
- While kirbyup will stay backwards compatible, exact build reproducibility may be of importance to you. If so, I recommend targeting a specific package version, rather than using `npx`. Install kirbyup with a package manager of your choice locally to your project:
45
-
46
- ```bash
47
- npm i kirbyup --save-dev
48
- ```
35
+ > [!TIP]
36
+ > [📖 Read the documentation](https://kirbyup.getkirby.com) or skip starting from scratch and pick one of the following starters:
37
+ > - [`eslint`](./examples/eslint)
38
+ > - [`tailwindcss`](./examples/tailwindcss)
49
39
 
50
- Example package configuration:
40
+ Having installed kirbyup, you can add the following scripts as shortcuts to the commands you will use most often:
51
41
 
52
42
  ```json
53
43
  {
@@ -56,197 +46,18 @@ Example package configuration:
56
46
  "build": "kirbyup src/index.js"
57
47
  },
58
48
  "devDependencies": {
59
- "kirbyup": "latest"
49
+ "kirbyup": "^3.1.3"
60
50
  }
61
51
  }
62
52
  ```
63
53
 
64
- Global installation is supported as well, but not recommended.
65
-
66
- ## Usage
67
-
68
- ### Development
69
-
70
- Start a development server for the Panel plugin:
71
-
72
- ```bash
73
- kirbyup serve src/index.js
74
- ```
75
-
76
- 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.
77
-
78
- If you prefer the watch mode to build a development bundle of the final Panel plugin or develop in an older version of Kirby (prior to 3.7.4), run:
79
-
80
- ```bash
81
- kirbyup src/index.js --watch
82
- ```
83
-
84
- ### Production
85
-
86
- ```bash
87
- kirbyup src/index.js
88
- ```
89
-
90
- The final panel plugin will be bundled, minified, and written into the current directory as `./index.js` and `./index.css`.
91
-
92
- ## Built-in Features
93
-
94
- ### PostCSS
95
-
96
- If the project contains a valid PostCSS config (any format supported by [postcss-load-config](https://github.com/postcss/postcss-load-config), e.g. `postcss.config.js`), it will be automatically applied to all imported CSS.
97
-
98
- If no configuration file is found, kirbyup will apply two PostCSS plugins which the Kirby Panel uses as well to let you embrace the same functionality within your Panel plugins. The following PostCSS transforms are applied by kirbyup:
99
-
100
- - [postcss-logical](https://github.com/csstools/postcss-logical) lets you use logical, rather than physical, direction and dimension mappings in CSS, following the [CSS Logical Properties and Values](https://drafts.csswg.org/css-logical/) specification.
101
- - [postcss-dir-pseudo-class](https://github.com/csstools/postcss-dir-pseudo-class) lets you style by directionality using the `:dir()` pseudo-class in CSS, following the [Selectors](https://www.w3.org/TR/selectors-4/#the-dir-pseudo) specification. It gives you the same syntax Kirby uses for full compatibility with RTL localizations of the Panel.
102
-
103
- ### Path Resolve Aliases
104
-
105
- Import certain modules more easily by using the `~/` path alias. It will resolve to the directory of your input file, for example `src` when building `kirbyup src/index.js`.
106
-
107
- Now, given a deeply nested component, instead of using relative paths when importing like so:
108
-
109
- ```js
110
- // Inside deeply nested module
111
- import someUtility from '../../utils'
112
- ```
113
-
114
- You can use the alias:
115
-
116
- ```js
117
- import someUtility from '~/utils'
118
- ```
119
-
120
- > [!TIP]
121
- > You can use `@/` as path alias as well.
122
-
123
- ### Auto-Import Blocks and Fields
124
-
125
- If you find yourself in the situation of needing to import multiple **blocks** or **fields** into your Panel plugin, you can use the kirbyup `kirbyup.import` function to ease the process.
126
-
127
- Before:
128
-
129
- ```js
130
- import Foo from './components/blocks/Foo.vue'
131
- import Bar from './components/blocks/Bar.vue'
132
- import Maps from './components/blocks/Maps.vue'
133
-
134
- window.panel.plugin('kirbyup/example', {
135
- blocks: {
136
- foo: Foo,
137
- bar: Bar,
138
- maps: Maps
139
- }
140
- })
141
- ```
142
-
143
- After:
144
-
145
- ```js
146
- import { kirbyup } from 'kirbyup/plugin'
147
-
148
- window.panel.plugin('kirbyup/example', {
149
- blocks: kirbyup.import('./components/blocks/*.vue')
150
- })
151
- ```
152
-
153
- ### Env Variables
154
-
155
- kirbyup exposes env variables on the special `import.meta.env` object. Some built-in variables are available in all cases:
156
-
157
- - **`import.meta.env.MODE`** (`development` | `production`): the mode kirbyup is running in.
158
- - **`import.meta.env.PROD`** (`boolean`): whether kirbyup is running in production.
159
- - **`import.meta.env.DEV`** (`boolean`): whether kirbyup is running in development (always the opposite of `import.meta.env.PROD`)
160
-
161
- During production, these env variables are **statically replaced**. It is therefore necessary to always reference them using the full static string. For example, dynamic key access like `import.meta.env[key]` will not work.
162
-
163
- #### `.env` Files
164
-
165
- kirbyup (thanks to Vite) uses [dotenv](https://github.com/motdotla/dotenv) to load additional environment variables from the `.env` and `.env.local` files in your plugin's root directory.
166
-
167
- Loaded env variables are also exposed to your source code via `import.meta.env`.
168
-
169
- To prevent accidentally leaking env variables for distribution, only variables prefixed with `KIRBYUP_` or `VITE_` are exposed to your processed code. Take the following file as an example:
170
-
171
- ```ini
172
- DB_PASSWORD=foobar
173
- KIRBYUP_SOME_KEY=123
174
- ```
175
-
176
- Only `KIRBYUP_SOME_KEY` will be exposed as `import.meta.env.VITE_SOME_KEY` to your plugin's source code, but `DB_PASSWORD` will not.
177
-
178
- ### Extendable Configuration With `kirbyup.config.js`
179
-
180
- Create a `kirbyup.config.js` or `kirbyup.config.ts` configuration file the root-level of your project to customize kirbyup.
181
-
182
- ```js
183
- import { fileURLToPath } from 'node:url'
184
- import { resolve } from 'node:path'
185
- import { defineConfig } from 'kirbyup/config'
186
-
187
- const currentDir = fileURLToPath(new URL('.', import.meta.url))
188
-
189
- export default defineConfig({
190
- alias: {
191
- '#plugin/': `${resolve(currentDir, 'src/plugin')}/`
192
- },
193
- vite: {
194
- define: {
195
- __PLAYGROUND__: JSON.stringify(process.env.PLAYGROUND)
196
- }
197
- }
198
- })
199
- ```
200
-
201
- #### `alias`
202
-
203
- When aliasing to file system paths, always use absolute paths. Relative alias values will be used as-is and will not be resolved into file system paths.
204
-
205
- #### `vite`
206
-
207
- You can build upon the defaults kirbup uses and extend the Vite configuration with custom plugins etc.
208
-
209
- For a complete list of options, take a look at the [Vite configuration options](https://vitejs.dev/config/).
210
-
211
- ## Options
212
-
213
- > [!TIP]
214
- > Inspect all available options with `kirbyup --help` and `kirbyup serve --help`.
215
-
216
- ### `kirbyup <input>`
217
-
218
- ##### `--out-dir <dir>`
219
-
220
- The output directory to save the processed code into. Defaults to the current working directory.
221
-
222
- ##### `--watch [path]`
223
-
224
- Enables watch mode. If no path is specified, kirbyup watches the folder of the input file. Repeat `--watch` for multiple paths.
225
-
226
- ### `kirbyup serve <input>`
227
-
228
- ##### `--port <port>`
229
-
230
- The port for the development server to run on. Defaults to `5177`.
231
-
232
- ##### `--out-dir <dir>`
233
-
234
- The output directory where the plugin file read by Kirby is saved. Defaults to the project root.
235
-
236
- ##### `--watch <path>`
237
-
238
- Specifies additional files that should be watched for changes, with changes causing the page to reload. Repeat `--watch` for multiple paths.
239
-
240
- > [!NOTE]
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.
246
-
247
- ## Credits
54
+ ## 💻 Development
248
55
 
249
- - [Vite](https://vitejs.dev) by Evan You and all of its contributors.
56
+ 1. Clone this repository
57
+ 2. Enable [Corepack](https://github.com/nodejs/corepack) using `corepack enable`
58
+ 3. Install dependencies using `pnpm install`
59
+ 4. Run `pnpm run dev:prepare`
60
+ 5. Start development server using `pnpm run dev`
250
61
 
251
62
  ## License
252
63
 
@@ -1,4 +1,4 @@
1
- import { U as UserConfig } from '../shared/kirbyup.1d99eeee.mjs';
1
+ import { U as UserConfig } from '../shared/kirbyup.DNMktHWN.mjs';
2
2
  import 'vite';
3
3
 
4
4
  declare function defineConfig(config: UserConfig): UserConfig;
@@ -1,4 +1,4 @@
1
- import { U as UserConfig } from '../shared/kirbyup.1d99eeee.js';
1
+ import { U as UserConfig } from '../shared/kirbyup.DNMktHWN.js';
2
2
  import 'vite';
3
3
 
4
4
  declare function defineConfig(config: UserConfig): UserConfig;
@@ -1,7 +1,7 @@
1
1
  declare const kirbyup: Readonly<{
2
2
  /**
3
- * Auto-import Kirby Panel components, will be transformed by
4
- * kirbyup's auto import plugin for Vite
3
+ * Auto-import Kirby Panel components, transformed by
4
+ * kirbyup's glob-import plugin for Vite.
5
5
  *
6
6
  * @example
7
7
  * kirbyup.import('./components/blocks/*.vue')
@@ -1,7 +1,7 @@
1
1
  declare const kirbyup: Readonly<{
2
2
  /**
3
- * Auto-import Kirby Panel components, will be transformed by
4
- * kirbyup's auto import plugin for Vite
3
+ * Auto-import Kirby Panel components, transformed by
4
+ * kirbyup's glob-import plugin for Vite.
5
5
  *
6
6
  * @example
7
7
  * kirbyup.import('./components/blocks/*.vue')
@@ -1,7 +1,7 @@
1
1
  const kirbyup = Object.freeze({
2
2
  /**
3
- * Auto-import Kirby Panel components, will be transformed by
4
- * kirbyup's auto import plugin for Vite
3
+ * Auto-import Kirby Panel components, transformed by
4
+ * kirbyup's glob-import plugin for Vite.
5
5
  *
6
6
  * @example
7
7
  * kirbyup.import('./components/blocks/*.vue')
package/dist/node/cli.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  import { cac } from 'cac';
2
- import { n as name, b as build, s as serve, v as version, h as handleError } from '../shared/kirbyup.5312ccaa.mjs';
2
+ import { n as name, b as build, s as serve, v as version, h as handleError } from '../shared/kirbyup.DSMJ9KWQ.mjs';
3
3
  import 'node:fs';
4
4
  import 'node:fs/promises';
5
5
  import 'pathe';
@@ -12,13 +12,13 @@ import '@vitejs/plugin-vue2';
12
12
  import '@vitejs/plugin-vue2-jsx';
13
13
  import 'vite-plugin-full-reload';
14
14
  import 'rollup-plugin-external-globals';
15
- import 'postcss-load-config';
16
- import 'postcss-logical';
17
- import 'postcss-dir-pseudo-class';
18
15
  import 'node:zlib';
19
16
  import 'node:util';
20
17
  import 'node:buffer';
21
18
  import 'c12';
19
+ import 'postcss-load-config';
20
+ import 'postcss-logical';
21
+ import 'postcss-dir-pseudo-class';
22
22
  import 'magic-string';
23
23
  import 'node:module';
24
24
 
@@ -1,5 +1,5 @@
1
1
  import * as vite from 'vite';
2
- import { B as BuildOptions, S as ServeOptions } from '../shared/kirbyup.1d99eeee.mjs';
2
+ import { B as BuildOptions, S as ServeOptions } from '../shared/kirbyup.DNMktHWN.mjs';
3
3
 
4
4
  declare function build(options: BuildOptions): Promise<void>;
5
5
  declare function serve(options: ServeOptions): Promise<vite.ViteDevServer>;
@@ -1,5 +1,5 @@
1
1
  import * as vite from 'vite';
2
- import { B as BuildOptions, S as ServeOptions } from '../shared/kirbyup.1d99eeee.js';
2
+ import { B as BuildOptions, S as ServeOptions } from '../shared/kirbyup.DNMktHWN.js';
3
3
 
4
4
  declare function build(options: BuildOptions): Promise<void>;
5
5
  declare function serve(options: ServeOptions): Promise<vite.ViteDevServer>;
@@ -10,13 +10,13 @@ import '@vitejs/plugin-vue2';
10
10
  import '@vitejs/plugin-vue2-jsx';
11
11
  import 'vite-plugin-full-reload';
12
12
  import 'rollup-plugin-external-globals';
13
- import 'postcss-load-config';
14
- import 'postcss-logical';
15
- import 'postcss-dir-pseudo-class';
16
- export { b as build, s as serve } from '../shared/kirbyup.5312ccaa.mjs';
13
+ export { b as build, s as serve } from '../shared/kirbyup.DSMJ9KWQ.mjs';
17
14
  import 'node:zlib';
18
15
  import 'node:util';
19
16
  import 'node:buffer';
20
17
  import 'c12';
18
+ import 'postcss-load-config';
19
+ import 'postcss-logical';
20
+ import 'postcss-dir-pseudo-class';
21
21
  import 'magic-string';
22
22
  import 'node:module';
@@ -15,8 +15,8 @@ interface BuildOptions extends BaseOptions {
15
15
  }
16
16
  interface UserConfig {
17
17
  /**
18
- * Specifies an `Object`, or an `Array` of `Object`,
19
- * which defines aliases used to replace values in `import` statements.
18
+ * Specifies an object or an array of objects, which defines aliases
19
+ * used to replace values in `import` statements.
20
20
  * With either format, the order of the entries is important,
21
21
  * in that the first defined rules are applied first.
22
22
  */
@@ -15,8 +15,8 @@ interface BuildOptions extends BaseOptions {
15
15
  }
16
16
  interface UserConfig {
17
17
  /**
18
- * Specifies an `Object`, or an `Array` of `Object`,
19
- * which defines aliases used to replace values in `import` statements.
18
+ * Specifies an object or an array of objects, which defines aliases
19
+ * used to replace values in `import` statements.
20
20
  * With either format, the order of the entries is important,
21
21
  * in that the first defined rules are applied first.
22
22
  */
@@ -10,18 +10,18 @@ import vuePlugin from '@vitejs/plugin-vue2';
10
10
  import vueJsxPlugin from '@vitejs/plugin-vue2-jsx';
11
11
  import fullReloadPlugin from 'vite-plugin-full-reload';
12
12
  import externalGlobals from 'rollup-plugin-external-globals';
13
- import postcssrc from 'postcss-load-config';
14
- import postcssLogical from 'postcss-logical';
15
- import postcssDirPseudoClass from 'postcss-dir-pseudo-class';
16
13
  import { gzip } from 'node:zlib';
17
14
  import { promisify } from 'node:util';
18
15
  import { Buffer } from 'node:buffer';
19
16
  import { loadConfig as loadConfig$1 } from 'c12';
17
+ import postcssrc from 'postcss-load-config';
18
+ import postcssLogical from 'postcss-logical';
19
+ import postcssDirPseudoClass from 'postcss-dir-pseudo-class';
20
20
  import MagicString from 'magic-string';
21
21
  import 'node:module';
22
22
 
23
23
  const name = "kirbyup";
24
- const version = "3.1.2";
24
+ const version = "3.1.4";
25
25
 
26
26
  class PrettyError extends Error {
27
27
  constructor(message) {
@@ -70,6 +70,17 @@ function loadConfig(cwd = process.cwd()) {
70
70
  }
71
71
  });
72
72
  }
73
+ async function resolvePostCSSConfig(cwd) {
74
+ try {
75
+ return await postcssrc(void 0, void 0, { stopDir: cwd });
76
+ } catch (error) {
77
+ if (!error.message.includes("No PostCSS Config found"))
78
+ throw error;
79
+ return {
80
+ plugins: [postcssLogical(), postcssDirPseudoClass()]
81
+ };
82
+ }
83
+ }
73
84
 
74
85
  const multilineCommentsRE = /\/\*(.|[\r\n])*?\*\//gm;
75
86
  const singlelineCommentsRE = /\/\/.*/g;
@@ -137,10 +148,10 @@ function $_applyKirbyModifications(activeDef, newDef) {
137
148
  /** -- */
138
149
  `;
139
150
 
140
- function kirbyupAutoImportPlugin() {
151
+ function kirbyupGlobImportPlugin() {
141
152
  let config;
142
153
  return {
143
- name: "kirbyup:auto-import",
154
+ name: "kirbyup:glob-import",
144
155
  configResolved(resolvedConfig) {
145
156
  config = resolvedConfig;
146
157
  },
@@ -260,19 +271,19 @@ async function detectPackageManager(cwd, options = {}) {
260
271
  function kirbyupHmrPlugin(options) {
261
272
  let config;
262
273
  let entry;
263
- let indexMjs;
274
+ let devIndexPath;
264
275
  return {
265
276
  name: "kirbyup:hmr",
266
277
  apply: "serve",
267
278
  configResolved(resolvedConfig) {
268
279
  config = resolvedConfig;
269
280
  entry = resolve(config.root, options.entry);
270
- indexMjs = resolve(config.root, options.outDir || "", "index.dev.mjs");
281
+ devIndexPath = resolve(config.root, options.outDir || "", "index.dev.mjs");
271
282
  },
272
283
  transform(code, id) {
273
284
  if (isHmrRuntimeId(id)) {
274
285
  return code.replace(
275
- // https://github.com/vitejs/vite-plugin-vue2/blob/06ede94/src/utils/hmrRuntime.ts#L173
286
+ // https://github.com/vitejs/vite-plugin-vue2/blob/8de73ea6b8a1df4c14308da2885db195dacc2b14/src/utils/hmrRuntime.ts#L173
276
287
  /^.*=\s*record\.Ctor\.super\.extend\(options\)/m,
277
288
  "$_applyKirbyModifications(record.Ctor.options, options) // injected by kirbyup\n$&"
278
289
  ) + __INJECTED_HMR_CODE__;
@@ -288,12 +299,12 @@ function kirbyupHmrPlugin(options) {
288
299
  const baseUrl = `http://${hostname}:${port}${config.base}`;
289
300
  const entryUrl = new URL(entryPath, baseUrl).href;
290
301
  const pm = await detectPackageManager(config.root);
291
- await writeFile(indexMjs, getViteProxyModule(entryUrl, pm));
302
+ await writeFile(devIndexPath, getViteProxyModule(entryUrl, pm));
292
303
  });
293
304
  },
294
305
  closeBundle() {
295
- if (existsSync(indexMjs))
296
- unlinkSync(indexMjs);
306
+ if (existsSync(devIndexPath))
307
+ unlinkSync(devIndexPath);
297
308
  }
298
309
  };
299
310
  }
@@ -307,21 +318,22 @@ try {
307
318
  "[kirbyup] Couldn't connect to the development server. Run \`${pm} run serve\` to start Vite or build the plugin with \`${pm} run build\` so Kirby uses the production version."
308
319
  );
309
320
  throw err;
310
- }`.trim();
321
+ }
322
+ `.trimStart();
311
323
  }
312
324
 
313
325
  function kirbyupBuildCleanupPlugin(options) {
314
326
  let config;
315
- let indexMjs;
327
+ let devIndexPath;
316
328
  return {
317
329
  name: "kirbyup:build-cleanup",
318
330
  configResolved(resolvedConfig) {
319
331
  config = resolvedConfig;
320
- indexMjs = resolve(config.root, options.outDir, "index.dev.mjs");
332
+ devIndexPath = resolve(config.root, options.outDir, "index.dev.mjs");
321
333
  },
322
334
  writeBundle() {
323
- if (existsSync(indexMjs))
324
- unlinkSync(indexMjs);
335
+ if (existsSync(devIndexPath))
336
+ unlinkSync(devIndexPath);
325
337
  }
326
338
  };
327
339
  }
@@ -345,7 +357,7 @@ function getViteConfig(command, options) {
345
357
  // looks in the current directory and breaks `npx kirbyup`
346
358
  vuePlugin({ compiler: vueCompilerSfc }),
347
359
  vueJsxPlugin(),
348
- kirbyupAutoImportPlugin(),
360
+ kirbyupGlobImportPlugin(),
349
361
  { ...externalGlobals({ vue: "Vue" }), enforce: "post" }
350
362
  ],
351
363
  css: { postcss: resolvedPostCssConfig },
@@ -358,8 +370,8 @@ function getViteConfig(command, options) {
358
370
  plugins: [
359
371
  kirbyupHmrPlugin(options),
360
372
  watch && fullReloadPlugin(watch)
361
- ],
362
- // Input needs to be specified so dep pre-bundling works
373
+ ].filter(Boolean),
374
+ // Input needs to be specified so dependency pre-bundling works
363
375
  build: { rollupOptions: { input: resolve(options.cwd, options.entry) } },
364
376
  // Specify origin so asset URLs include Vite server host
365
377
  server: { port, strictPort: true, origin: `http://localhost:${port}` }
@@ -407,12 +419,7 @@ async function generate(options) {
407
419
  if (l > longest)
408
420
  longest = l;
409
421
  }
410
- for (const {
411
- fileName,
412
- type,
413
- // @ts-expect-error: `code` not available in `OutputAsset`
414
- code
415
- } of output) {
422
+ for (const { fileName, type, code } of output) {
416
423
  await printFileInfo(
417
424
  options.cwd,
418
425
  options.outDir,
@@ -446,7 +453,7 @@ async function build(options) {
446
453
  const { watch } = await import('chokidar');
447
454
  const ignored = [
448
455
  "**/{.git,node_modules}/**",
449
- // Always ignore out files
456
+ // Always ignore dist files
450
457
  "index.{css,js}"
451
458
  ];
452
459
  const watchPaths = typeof options.watch === "boolean" ? dirname(options.entry) : Array.isArray(options.watch) ? options.watch.filter(
@@ -464,7 +471,8 @@ async function build(options) {
464
471
  if (configFile)
465
472
  watcher.add(configFile);
466
473
  watcher.on("all", async (type, file) => {
467
- if (configFile === file) {
474
+ const absolutePath = resolve(cwd, file);
475
+ if (configFile === absolutePath) {
468
476
  resolvedKirbyupConfig = (await loadConfig(cwd)).config ?? {};
469
477
  consola.info(
470
478
  `${colors.cyan(basename(file))} changed, setting new config`
@@ -498,17 +506,5 @@ function ensureEntry(options) {
498
506
  if (!existsSync(resolve(options.cwd, options.entry)))
499
507
  throw new PrettyError(`Cannot find "${options.entry}"`);
500
508
  }
501
- async function resolvePostCSSConfig(cwd) {
502
- try {
503
- const config = await postcssrc(void 0, void 0, { stopDir: cwd });
504
- return config;
505
- } catch (error) {
506
- if (!error.message.includes("No PostCSS Config found"))
507
- throw error;
508
- return {
509
- plugins: [postcssLogical(), postcssDirPseudoClass()]
510
- };
511
- }
512
- }
513
509
 
514
510
  export { build as b, handleError as h, name as n, serve as s, version as v };
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "kirbyup",
3
3
  "type": "module",
4
- "version": "3.1.2",
5
- "packageManager": "pnpm@8.15.1",
4
+ "version": "3.1.4",
5
+ "packageManager": "pnpm@8.15.3",
6
6
  "description": "Zero-config bundler for Kirby Panel plugins",
7
7
  "author": {
8
8
  "name": "Johann Schopplich",
@@ -61,6 +61,9 @@
61
61
  "scripts": {
62
62
  "build": "unbuild",
63
63
  "dev": "UNBUILD_STUB=true unbuild",
64
+ "docs": "pnpm -C docs run dev",
65
+ "docs:build": "pnpm -C docs run build",
66
+ "docs:serve": "pnpm -C docs run serve",
64
67
  "lint": "eslint .",
65
68
  "lint:fix": "eslint . --fix",
66
69
  "release": "bumpp --commit --push --tag",
@@ -72,27 +75,27 @@
72
75
  "@vitejs/plugin-vue2": "2.2.0",
73
76
  "@vitejs/plugin-vue2-jsx": "1.1.0",
74
77
  "@vue/compiler-sfc": "^2.7.16",
75
- "c12": "^1.6.1",
78
+ "c12": "^1.8.0",
76
79
  "cac": "^6.7.14",
77
- "chokidar": "^3.5.3",
80
+ "chokidar": "^3.6.0",
78
81
  "consola": "^3.2.3",
79
- "magic-string": "^0.30.5",
82
+ "magic-string": "^0.30.7",
80
83
  "pathe": "^1.1.2",
81
84
  "perfect-debounce": "^1.0.0",
82
- "postcss": "^8.4.33",
85
+ "postcss": "^8.4.35",
83
86
  "postcss-dir-pseudo-class": "^8.0.1",
84
- "postcss-load-config": "^5.0.2",
87
+ "postcss-load-config": "^5.0.3",
85
88
  "postcss-logical": "^7.0.1",
86
89
  "rollup-plugin-external-globals": "^0.9.2",
87
90
  "sass": "^1.70.0",
88
- "vite": "^5.0.12",
91
+ "vite": "^5.1.2",
89
92
  "vite-plugin-full-reload": "^1.1.0",
90
93
  "vue": "^2.7.16"
91
94
  },
92
95
  "devDependencies": {
93
- "@antfu/eslint-config": "^2.6.3",
96
+ "@antfu/eslint-config": "^2.6.4",
94
97
  "@types/fs-extra": "^11.0.4",
95
- "@types/node": "^20.11.10",
98
+ "@types/node": "^20.11.18",
96
99
  "@types/prompts": "^2.4.9",
97
100
  "bumpp": "^9.3.0",
98
101
  "eslint": "^8.56.0",
@@ -101,7 +104,7 @@
101
104
  "nypm": "^0.3.6",
102
105
  "simple-git-hooks": "^2.9.0",
103
106
  "typescript": "~5.3.3",
104
- "unbuild": "^2.0.0",
107
+ "unbuild": "^3.0.0-rc.1",
105
108
  "vitest": "^1.2.2"
106
109
  },
107
110
  "simple-git-hooks": {