···1+# Folder structure
2+3+- `src` - source code for your kaplay project
4+- `dist` - distribution folder, contains your index.html, built js bundle and static assets
5+6+7+## Development
8+9+```sh
10+$ bun run dev
11+```
12+13+will start a dev server at http://localhost:8000
14+15+## Distribution
16+17+```sh
18+$ bun run build
19+```
20+21+will build your js files into `dist/`
22+23+```sh
24+$ bun run zip
25+```
26+27+will build your game and package into a .zip file, you can upload to your server or itch.io / newground etc.
···1+import kaplay from "kaplay";
2+// import "kaplay/global"; // uncomment if you want to use without the k. prefix
3+4+const k = kaplay();
5+6+k.loadRoot("./"); // A good idea for Itch.io publishing later
7+k.loadSprite("bean", "sprites/bean.png");
8+9+k.add([k.pos(120, 80), k.sprite("bean")]);
10+11+k.onClick(() => k.addKaboom(k.mousePos()));
+37
vite.config.js
···0000000000000000000000000000000000000
···1+import { defineConfig } from "vite";
2+3+const kaplayCongrats = () => {
4+ return {
5+ name: "vite-plugin-kaplay-hello",
6+ buildEnd() {
7+ const line =
8+ "---------------------------------------------------------";
9+ const msg = `🦖 Awesome pal! Send your game to us:\n\n💎 Discord: https://discord.com/invite/aQ6RuQm3TF \n💖 Donate to KAPLAY: https://opencollective.com/kaplay\n\ (you can disable this msg on vite.config)`;
10+11+ process.stdout.write(`\n${line}\n${msg}\n${line}\n`);
12+ },
13+ };
14+};
15+16+export default defineConfig({
17+ // index.html out file will start with a relative path for script
18+ base: "./",
19+ server: {
20+ port: 3001,
21+ },
22+ build: {
23+ // disable this for low bundle sizes
24+ sourcemap: true,
25+ rollupOptions: {
26+ output: {
27+ manualChunks: {
28+ kaplay: ["kaplay"],
29+ },
30+ },
31+ },
32+ },
33+ plugins: [
34+ // Disable messages removing this line
35+ kaplayCongrats(),
36+ ],
37+});