All Projects â†’ johannschopplich â†’ kirbyup

johannschopplich / kirbyup

Licence: MIT license
🆙 Zero-config bundler for Kirby Panel plugins

Programming Languages

typescript
32286 projects
javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to kirbyup

kirby-boiler-field
Boilerplate for Kirby form fields
Stars: ✭ 15 (-54.55%)
Mutual labels:  kirby, kirby-cms, kirby-plugin, kirby-panel
content-viewer
A nifty little Kirby widget that allows you to show a block of Kirbytext or Markdown content in Kirby's panel.
Stars: ✭ 16 (-51.52%)
Mutual labels:  kirby-cms, kirby-plugin, kirby-panel
kirby3-many-to-many-field
This plugin allows you to create many-to-many relationships between pages in Kirby and synchronizes them on both sides.
Stars: ✭ 38 (+15.15%)
Mutual labels:  kirby, kirby-cms, kirby-plugin
kirby-membership
Simple Membership plugin for Kirby CMS
Stars: ✭ 27 (-18.18%)
Mutual labels:  kirby, kirby-cms, kirby-plugin
kirby-minify-html
Enable minify HTML output for Kirby 3
Stars: ✭ 27 (-18.18%)
Mutual labels:  kirby, kirby-cms, kirby-plugin
kirby-git
Kirby plugin for updating content in the panel via Git
Stars: ✭ 75 (+127.27%)
Mutual labels:  kirby, kirby-cms, kirby-panel
field-engineer
A Kirby field for complex field structures.
Stars: ✭ 49 (+48.48%)
Mutual labels:  kirby, kirby-cms, kirby-plugin
kirby-podcast
A KirbyCMS-Podcast-Plugin
Stars: ✭ 22 (-33.33%)
Mutual labels:  kirby, kirby-cms, kirby-plugin
kirby-blade
Enable Laravel Blade Template Engine for Kirby 3
Stars: ✭ 20 (-39.39%)
Mutual labels:  kirby, kirby-cms, kirby-plugin
search-for-kirby
Kirby 3 plugin for adding a search index (sqlite or Algolia).
Stars: ✭ 42 (+27.27%)
Mutual labels:  kirby, kirby-cms, kirby-plugin
kirby-copy-files
Clone page dashboard widget for Kirby panel
Stars: ✭ 12 (-63.64%)
Mutual labels:  kirby, kirby-plugin, kirby-panel
retour-for-kirby
Kirby 3 plugin to manage redirects and track 404s right from the Panel
Stars: ✭ 96 (+190.91%)
Mutual labels:  kirby, kirby-cms, kirby-plugin
laravel-mix-kirby
Laravel Mix helper for Kirby
Stars: ✭ 23 (-30.3%)
Mutual labels:  kirby, kirby-cms, kirby-plugin
kirby-highlight
Themeable server-side syntax highlighting for Kirby
Stars: ✭ 14 (-57.58%)
Mutual labels:  kirby, kirby-cms, kirby-plugin
kirby-hashed-assets
🛷 File name hashes support for css() and js() helpers. Without rewrite rules!
Stars: ✭ 15 (-54.55%)
Mutual labels:  kirby, kirby-plugin
kirby-backup-widget
Kirby panel widget to easily backup your site content.
Stars: ✭ 25 (-24.24%)
Mutual labels:  kirby, kirby-panel
kirby-blade-template
âŦĸ Laravel Blade template component for Kirby CMS.
Stars: ✭ 26 (-21.21%)
Mutual labels:  kirby-cms, kirby-plugin
monochrome
A fully responsive Kirby CMS theme
Stars: ✭ 27 (-18.18%)
Mutual labels:  kirby, kirby-cms
KirbyComments
[Kirby 2] File-based comments stored as subpages for the Kirby CMS.
Stars: ✭ 68 (+106.06%)
Mutual labels:  kirby, kirby-plugin
kirby-securedpages
Protect pages for authenticated users
Stars: ✭ 28 (-15.15%)
Mutual labels:  kirby-cms, kirby-plugin

kirbyup

Take a look into Kirby's pluginkit repository for an example setup.

The fastest and leanest way to bundle your Kirby Panel plugins. No configuration necessary.

Key Features

Requirements

  • Node 14+ (Node 16 recommended)

ℹī¸ When using kirbyup with npx, npm 7+ is required. Previous versions don't pass cli arguments to the package invoked. npm 7 is bundled from Node 16 onwards.

Get Started Right Away

â€Ļ With one of the following Panel plugin kits:

Installation

If you want to use kirbyup right away, there is no need to install it. Simply call it with npx:

{
  "scripts": {
    "dev": "npx -y kirbyup src/index.js --watch",
    "build": "npx -y kirbyup src/index.js"
  }
}

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.

While kirbyup will stay backwards compatible, exact build reproducibility may be of importance to you. If so, I recommend to target a specific package version, rather than using npx. Install kirbyup with a package manager of your choice locally to your project:

npm i kirbyup --save-dev

Example package configuration:

{
  "scripts": {
    "dev": "kirbyup src/index.js --watch",
    "build": "kirbyup src/index.js"
  },
  "devDependencies": {
    "kirbyup": "latest"
  }
}

Global installation is supported as well, but not recommended.

Usage

Development

Rebuild the Panel plugin on any file changes:

kirbyup src/index.js --watch

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).

kirbyup src/index.js --watch src

You can specify more than a single directory:

kirbyup src/index.js --watch src --watch libs

Production

kirbyup src/index.js

The final panel plugin will be bundled, minified, and written into the current directory as ./index.js.

Built-in Features

PostCSS

If the project contains a valid PostCSS config (any format supported by postcss-load-config, e.g. postcss.config.js), it will be automatically applied to all imported CSS.

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:

Path Resolve Aliases

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.

Now, given a deeply nested component, instead of using relative paths when importing like so:

// Inside deeply nested module
import someUtility from '../../utils'

You can use the alias:

import someUtility from '~/utils'

ℹī¸ You can use @/ as path alias as well.

Auto-Import Blocks and Fields

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.

Before:

import Foo from './components/blocks/Foo.vue'
import Bar from './components/blocks/Bar.vue'
import Maps from './components/blocks/Maps.vue'

window.panel.plugin('kirbyup/example', {
  blocks: {
    foo: Foo,
    bar: Bar,
    maps: Maps
  }
})

After:

import { kirbyup } from 'kirbyup/plugin'

window.panel.plugin('kirbyup/example', {
  blocks: kirbyup.import('./components/blocks/*.vue')
})

Env Variables

kirbyup exposes env variables on the special import.meta.env object. Some built-in variables are available in all cases:

  • import.meta.env.MODE: {development | production} the mode kirbyup is running in.
  • import.meta.env.PROD: {boolean} whether kirbyup is running in production.
  • import.meta.env.DEV: {boolean} whether kirbyup is running in development (always the opposite of import.meta.env.PROD)

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.

.env Files

kirbyup (thanks to Vite) uses dotenv to load additional environment variables from the following files in your plugin's root directory:

.env                # loaded in all cases
.env.local          # loaded in all cases, ignored by git
.env.[mode]         # only loaded in specified mode
.env.[mode].local   # only loaded in specified mode, ignored by git

Loaded env variables are also exposed to your source code via import.meta.env.

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:

DB_PASSWORD=foobar
KIRBYUP_SOME_KEY=123

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.

Extendable Configuration With kirbyup.config.js

Create a kirbyup.config.js or kirbyup.config.ts configuration file the root-level of your project to customize kirbyup.

import { resolve } from 'path'
import { defineConfig } from 'kirbyup'

export default defineConfig({
  alias: {
    '#deep/': `${resolve(__dirname, 'src/deep')}/`
  },
  extendViteConfig: {
    build: {
      lib: {
        name: 'myPlugin'
      }
    }
  }
})

alias

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.

extendViteConfig

You can build upon the defaults kirbup uses and extend the Vite configuration with custom plugins etc.

For a complete list of options, take a look at the Vite configuration options.

Options

Inspect all available options with kirbyup --help.

--out-dir

The output directory to save the processed code into. Defaults to the current working directory.

--watch

Sets the watch mode. If no path is specified, kirbyup watches the folder of the input file. Repeat --watch for multiple paths.

Credits

  • Vite by Evan You and all of its contributors.
  • EGOIST for his inspirational work on tsup.

License

MIT License Š 2021 Johann Schopplich

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].