Kirby Panel Plugin Bundler
kirbyup is a zero-configuration bundler specifically designed for Kirby Panel plugins. It streamlines the development and build process by leveraging Vite internally, providing fast Hot Module Replacement (HMR) during development and optimized production builds. The current stable version is 3.4.1, with active development progressing towards v4.0.0, which introduces significant breaking changes related to Vue 3 migration. Its primary differentiator is its tailored approach for the Kirby CMS ecosystem, abstracting away complex bundler configurations for panel developers and allowing them to focus on plugin logic rather than build tooling. The project exhibits a steady release cadence, marked by regular updates and ongoing alpha releases for its next major version. It supports Node.js environments version 18 and above and ships with TypeScript types, facilitating modern JavaScript and TypeScript development workflows for Kirby plugins.
Common errors
-
ReferenceError: window is not defined
cause This error typically occurs in Node.js environments when browser-specific APIs (like `window`) are accessed, often due to a dependency issue, particularly with `c12` prior to v3.4.1.fixUpdate `kirbyup` to v3.4.1 or higher. If using `npx`, ensure you specify `@latest` (`npx -y kirbyup@latest`) or install `kirbyup` as a local dev dependency and use `npm run` scripts. -
Vue 2 options (e.g., `data` as an object, `$children`, `$listeners`) are not working as expected in my Kirby Panel plugin.
cause You are likely using a `kirbyup` v4.0.0-alpha release, which has migrated to Vue 3. Vue 3 has numerous breaking changes from Vue 2, causing incompatibility with older plugin code.fixMigrate your Kirby Panel plugin's Vue components and related logic from Vue 2 to Vue 3 syntax and APIs. Consult the official Vue 3 Migration Guide for a comprehensive list of changes, including updates to global APIs, template directives, and instance properties.
Warnings
- breaking kirbyup v4.0.0-alpha introduces a breaking change by migrating to Vue 3. This means any existing Kirby Panel plugins built with Vue 2 will require updates to be compatible, including changes to Vuex usage, global APIs, template directives, and removed instance properties like `$children` and `$listeners`.
- gotcha When invoking `kirbyup` via `npx`, particularly with older Node.js versions or specific configurations, users might encounter `ReferenceError: window is not defined`. This was addressed in v3.4.1 by pinning the `c12` dependency.
- gotcha `kirbyup` requires Node.js version 18 or higher. Using older Node.js versions will result in installation failures or runtime errors due to incompatible JavaScript features or dependencies.
- gotcha Using `npx` to run `kirbyup` can sometimes lead to cached outdated versions, even if a newer version is available. This might prevent you from accessing the latest features or bug fixes.
Install
-
npm install kirbyup -
yarn add kirbyup -
pnpm add kirbyup
Imports
- defineConfig
import { defineConfig } from 'kirbyup'import { defineConfig } from 'kirbyup/config' - CLI Execution (npm script)
node_modules/.bin/kirbyup serve src/index.js
"dev": "kirbyup serve src/index.js"
- CLI Execution (npx)
npx kirbyup serve src/index.js
npx kirbyup serve src/index.js
Quickstart
{
"name": "my-kirby-plugin",
"version": "1.0.0",
"type": "module",
"scripts": {
"dev": "kirbyup serve src/index.js",
"build": "kirbyup src/index.js"
},
"devDependencies": {
"kirbyup": "^3.4.1"
}
}
// kirbyup.config.ts
import { defineConfig } from 'kirbyup/config'
import { resolve } from 'node:path'
import { fileURLToPath } from 'node:url'
const currentDir = fileURLToPath(new URL('.', import.meta.url))
export default defineConfig({
alias: {
// Example: Alias for Panel core components if you clone Kirby repo
'@/': `${resolve(currentDir, 'kirby/panel/src')}/`
},
vite: {
// Custom Vite options (e.g., add plugins)
css: {
preprocessorOptions: {
scss: { /* ... */ }
}
}
}
})
// src/index.js (your plugin entry point)
// Example: A simple Vue component for your Kirby Panel plugin
import { createApp } from 'vue'
import MyPanelComponent from './components/MyPanelComponent.vue'
panel.plugin('your/plugin', {
sections: {
'my-custom-section': {
component: MyPanelComponent,
props: ['headline']
}
}
})