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.
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}:
$ playcademy vite configThis will:
- Install
@playcademy/vite-plugin - Update or create
vite.config.ts - Add the plugin to your configuration
Manual Setup
bun add -D @playcademy/vite-pluginnpm install -D @playcademy/vite-pluginpnpm add -D @playcademy/vite-pluginyarn add -D @playcademy/vite-pluginimport { 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:
- Platform mode simulates being launched inside the Playcademy platform
- Standalone mode simulates direct access without platform integration
Switch between modes with the m + enter hotkey.
playcademy({
mode: 'platform',
})| Option | Type | Default | Description |
|---|---|---|---|
mode | 'platform' | 'standalone' | 'platform' | Plugin operation mode |
Export Options
Control build output:
playcademy({
export: {
autoZip: true,
},
})| Option | Type | Default | Description |
|---|---|---|---|
autoZip | boolean | true | Create deployment zip archive |
Sandbox Options
Configure the local development sandbox:
playcademy({
sandbox: {
autoStart: true,
recreateDb: false,
seed: true,
memoryOnly: false,
databasePath: undefined,
},
})| Option | Type | Default | Description |
|---|---|---|---|
autoStart | boolean | true | Auto-start sandbox with dev server |
url | string | undefined | Custom sandbox URL (disables autoStart) |
verbose | boolean | false | Enable verbose logging |
logLevel | string | 'info' | Log level: debug, info, warn, error |
recreateDb | boolean | false | Recreate database on each start |
seed | boolean | true | Seed database with demo data |
memoryOnly | boolean | false | Use in-memory database (non-persistent) |
databasePath | string | undefined | Custom database file path |
Display Options
Configure visual elements during development:
playcademy({
display: {
hideBadge: true,
},
})| Option | Type | Default | Description |
|---|---|---|---|
hideBadge | boolean | false | Hide 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:
playcademy({
timeback: {
id: '...',
role: 'teacher',
organization: { id: '...', name: '...', type: 'school' },
courses: { 'FastMath:3': '...' },
},
})| Option | Type | Default | Description |
|---|---|---|---|
id | string | auto-mock | Real student sourcedId for live testing |
role | string | 'student' | student, parent, teacher, administrator, or guardian |
organization | object | 'mock' | Custom org with id, name, type |
courses | object | auto-enroll | Map 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
playcademy({
mode: 'standalone',
})Disable Auto-Zip
Auto-zip is enabled by default. To disable:
playcademy({
export: {
autoZip: false,
},
})Hide Playcademy Badge
playcademy({
display: {
hideBadge: true,
},
})Reset Sandbox Data on Launch
Useful for testing fresh database states:
playcademy({
sandbox: {
recreateDb: true,
},
})In-Memory Database
Use RAM-based database in ephemeral contexts:
playcademy({
sandbox: {
memoryOnly: true,
},
})Custom Database Path
Specify a custom location for the database file:
playcademy({
sandbox: {
databasePath: './dev-sandbox.db',
},
})