Skip to content
Get started

Vite plugin and configuration

View as Markdown

Today, mk dev and mk publish find a game by convention: src/game.ts and network/velocity.ts. The plan is one configuration that says what a project builds and where it goes, like a Cloudflare Workers project with its Vite plugin and Wrangler.

vite.config.ts
import { minekube } from "@minekube/vite";
import { defineConfig } from "vite";
export default defineConfig({
plugins: [
minekube({
bundles: {
arena: { platform: "paper", entry: "src/game.ts" },
lobby: { platform: "velocity", entry: "network/velocity.ts" },
},
targets: {
canary: { network: "play", selector: "channel=canary" },
prod: {
network: "play",
selector: "*",
hostnames: ["arena"],
domains: ["arena.example.com"],
},
},
}),
],
});
  • bundles is required. Nothing is built by convention. Name, platform and entry are explicit, and a project can have several bundles per platform.
  • targets are where mk deploy goes, like Wrangler’s environments. With one target, mk deploy needs no argument.
  • selector is required. All servers of a network are "*", written out, so a forgotten selector never rolls out to everyone.
  • There are no build commands. The build is Vite itself. An extra step is a Vite plugin or a script in package.json.
  • The plugin checks the configuration with an Effect Schema and names the field that is wrong.

The Vite plugin and mk share one core: read and check the configuration, build, run the dev server, install and upload. mk dev, mk build and mk deploy call the same functions as vite dev and vite build. Paper and Velocity become environments of Vite’s Environment API, as Cloudflare’s plugin runs workerd. Bun stays the runtime, package manager and test runner.

vite build writes dist/ with the bundles and a minekube.json that names each bundle with its platform and SHA-256. What you tested is what you upload.

Today Planned Like
mk publish mk deploy [target]: build, upload, assign wrangler deploy
mk versions upload: upload without assigning wrangler versions upload
mk versions deploy <id> [--batch 20%] wrangler versions deploy
mk revisions mk versions list, mk deployments list wrangler versions list, deployments list
mk publish --revision mk rollback [id] wrangler rollback
mk unpublish mk undeploy [target]

--message and --tag describe a version. Without them, mk deploy takes the commit message and hash from git. The network keeps the last 100 versions and every version that is assigned.

Was this helpful?