PlaycademyPlaycademy

Vite Plugin

Seamless Vite integration for Playcademy development

Overview

The @playcademy/vite-plugin provides a streamlined local dev setup + build preparation for Vite-based projects.

Vite plugin architecture showing development stack

The plugin works out of the box for most projects.

Just add it to your vite.config.ts file and run vite dev to get started.


Installation

Automatic Setup

If you have an existing Playcademy project with playcademy.config.{js,json}:

Command
$ playcademy vite config

This will:

  1. Install @playcademy/vite-plugin
  2. Update or create vite.config.ts
  3. Add the plugin to your configuration

Manual Setup

bun add -D @playcademy/vite-plugin
npm install -D @playcademy/vite-plugin
pnpm add -D @playcademy/vite-plugin
yarn add -D @playcademy/vite-plugin
vite.config.ts
import { defineConfig } from 'vite'

import { playcademy } from '@playcademy/vite-plugin'

export default defineConfig({
    plugins: [playcademy()],
})

That's it. Run your dev command and the plugin handles the rest.


Configuration

Plugin Mode

When deploying to Playcademy, you'll be given two URLs: a platform link and a standalone link.

Platform vs. Standalone

Configuring the plugin's mode option lets you develop against your chosen scenario:

  1. Platform mode simulates being launched inside the Playcademy platform
  2. Standalone mode simulates direct access without platform integration

Switch between modes with the m + enter hotkey.

vite.config.ts
playcademy({
    mode: 'platform',
})
OptionTypeDefaultDescription
mode'platform' | 'standalone''platform'Plugin operation mode

Export Options

Control build output:

vite.config.ts
playcademy({
    export: {
        autoZip: true,
    },
})
OptionTypeDefaultDescription
autoZipbooleantrueCreate deployment zip archive

Sandbox Options

Configure the local development sandbox:

vite.config.ts
playcademy({
    sandbox: {
        autoStart: true,
        recreateDb: false,
        seed: true,
        memoryOnly: false,
        databasePath: undefined,
    },
})
OptionTypeDefaultDescription
autoStartbooleantrueAuto-start sandbox with dev server
urlstringundefinedCustom sandbox URL (disables autoStart)
verbosebooleanfalseEnable verbose logging
logLevelstring'info'Log level: debug, info, warn, error
recreateDbbooleanfalseRecreate database on each start
seedbooleantrueSeed database with demo data
memoryOnlybooleanfalseUse in-memory database (non-persistent)
databasePathstringundefinedCustom database file path

Display Options

Configure visual elements during development:

vite.config.ts
playcademy({
    display: {
        hideBadge: true,
    },
})
OptionTypeDefaultDescription
hideBadgebooleanfalseHide Playcademy corner badge

Timeback Options

All courses from your playcademy.config.js are automatically enrolled with mock data.

You can override defaults for testing purposes:

vite.config.ts
playcademy({
    timeback: {
        id: '...',
        role: 'teacher',
        organization: { id: '...', name: '...', type: 'school' },
        courses: { 'FastMath:3': '...' },
    },
})
OptionTypeDefaultDescription
idstringauto-mockReal student sourcedId for live testing
rolestring'student'student, parent, teacher, administrator, or guardian
organizationobject'mock'Custom org with id, name, type
coursesobjectauto-enrollMap of course keys to 'mock', real sourcedId, or null

Hotkeys

Press t in the terminal to cycle through roles during development.

Read more about local development with Timeback.


Common Configurations

Standalone Mode

vite.config.ts
playcademy({
    mode: 'standalone',
})

Disable Auto-Zip

Auto-zip is enabled by default. To disable:

vite.config.ts
playcademy({
    export: {
        autoZip: false,
    },
})

Hide Playcademy Badge

vite.config.ts
playcademy({
    display: {
        hideBadge: true,
    },
})

Reset Sandbox Data on Launch

Useful for testing fresh database states:

vite.config.ts
playcademy({
    sandbox: {
        recreateDb: true,
    },
})

In-Memory Database

Use RAM-based database in ephemeral contexts:

vite.config.ts
playcademy({
    sandbox: {
        memoryOnly: true,
    },
})

Custom Database Path

Specify a custom location for the database file:

vite.config.ts
playcademy({
    sandbox: {
        databasePath: './dev-sandbox.db',
    },
})

What's Next?

On this page