@playcademy/vite-plugin 0.0.1-beta.2 → 0.0.1-beta.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +289 -49
- package/dist/index.d.ts +11 -0
- package/dist/index.js +121536 -0
- package/dist/lib/manifest.d.ts +8 -0
- package/dist/lib/sandbox.d.ts +3 -0
- package/dist/lib/server.d.ts +3 -0
- package/dist/pglite.data +0 -0
- package/dist/pglite.wasm +0 -0
- package/dist/types.d.ts +65 -0
- package/dist/types.js +0 -0
- package/dist/utils.d.ts +8 -0
- package/package.json +20 -10
- package/build.ts +0 -45
- package/src/index.ts +0 -219
- package/sst-env.d.ts +0 -9
- package/tsconfig.json +0 -28
- package/tsconfig.types.json +0 -13
package/README.md
CHANGED
|
@@ -1,102 +1,342 @@
|
|
|
1
1
|
# @playcademy/vite-plugin
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
**Vite plugin for Playcademy game development and deployment**
|
|
4
|
+
|
|
5
|
+
This plugin integrates Playcademy's development sandbox and build tools into your Vite workflow, automatically generating manifests, managing development environments, and creating deployment-ready archives.
|
|
6
|
+
|
|
7
|
+
## Overview
|
|
8
|
+
|
|
9
|
+
The Playcademy Vite plugin streamlines game development by providing:
|
|
10
|
+
|
|
11
|
+
- **Development Sandbox**: Automatically starts a local Playcademy API server during development
|
|
12
|
+
- **Manifest Generation**: Creates required `playcademy.manifest.json` files for platform deployment
|
|
13
|
+
- **Build Optimization**: Configures Vite settings for optimal Playcademy platform compatibility
|
|
14
|
+
- **Deployment Packaging**: Optionally creates zip archives ready for platform upload
|
|
15
|
+
|
|
16
|
+
### Key Benefits
|
|
17
|
+
|
|
18
|
+
- **Zero-Config Development**: Works out of the box with sensible defaults
|
|
19
|
+
- **Hot Reload Integration**: Seamless development experience with Vite's hot module replacement
|
|
20
|
+
- **Platform Compatibility**: Ensures builds work correctly on the Playcademy platform
|
|
21
|
+
- **Type Safety**: Full TypeScript support with comprehensive type definitions
|
|
22
|
+
- **Flexible Configuration**: Extensive options for customizing both development and build processes
|
|
4
23
|
|
|
5
24
|
## Installation
|
|
6
25
|
|
|
26
|
+
Install the plugin in your Playcademy game project:
|
|
27
|
+
|
|
7
28
|
```bash
|
|
8
|
-
# Using
|
|
29
|
+
# Using Bun (recommended)
|
|
9
30
|
bun add -D @playcademy/vite-plugin
|
|
10
31
|
|
|
11
|
-
# Using
|
|
12
|
-
|
|
32
|
+
# Using npm
|
|
33
|
+
npm install --save-dev @playcademy/vite-plugin
|
|
13
34
|
|
|
14
35
|
# Using yarn
|
|
15
36
|
yarn add --dev @playcademy/vite-plugin
|
|
16
37
|
|
|
17
|
-
# Using
|
|
18
|
-
|
|
38
|
+
# Using pnpm
|
|
39
|
+
pnpm add -D @playcademy/vite-plugin
|
|
19
40
|
```
|
|
20
41
|
|
|
21
|
-
##
|
|
42
|
+
## Quick Start
|
|
22
43
|
|
|
23
|
-
Add the plugin to your `vite.config.ts
|
|
44
|
+
Add the plugin to your `vite.config.ts`:
|
|
24
45
|
|
|
25
46
|
```typescript
|
|
26
|
-
// vite.config.ts
|
|
27
47
|
import { defineConfig } from 'vite'
|
|
48
|
+
|
|
49
|
+
import { playcademy } from '@playcademy/vite-plugin'
|
|
50
|
+
|
|
51
|
+
export default defineConfig({
|
|
52
|
+
plugins: [
|
|
53
|
+
playcademy(), // Uses all defaults
|
|
54
|
+
],
|
|
55
|
+
})
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
Start development:
|
|
59
|
+
|
|
60
|
+
```bash
|
|
61
|
+
bun dev
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
The plugin will:
|
|
65
|
+
|
|
66
|
+
- Start the sandbox server at `http://localhost:4321/api`
|
|
67
|
+
- Enable API integration for your game
|
|
68
|
+
- Provide hot reload for rapid development
|
|
69
|
+
|
|
70
|
+
## Configuration
|
|
71
|
+
|
|
72
|
+
### Basic Configuration
|
|
73
|
+
|
|
74
|
+
```typescript
|
|
28
75
|
import { playcademy } from '@playcademy/vite-plugin'
|
|
29
76
|
|
|
30
77
|
export default defineConfig({
|
|
31
78
|
plugins: [
|
|
32
79
|
playcademy({
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
80
|
+
export: {
|
|
81
|
+
bootMode: 'iframe', // 'iframe' | 'module'
|
|
82
|
+
entryPoint: 'index.html', // Main HTML file
|
|
83
|
+
platform: 'web', // 'web' | 'godot' | 'unity'
|
|
84
|
+
autoZip: false, // Create deployment zip
|
|
85
|
+
styles: [], // Additional CSS files
|
|
86
|
+
},
|
|
87
|
+
sandbox: {
|
|
88
|
+
autoStart: true, // Start sandbox automatically
|
|
89
|
+
url: 'http://localhost:4321/api', // Sandbox URL
|
|
90
|
+
verbose: false, // Enable debug logging
|
|
91
|
+
},
|
|
92
|
+
}),
|
|
93
|
+
],
|
|
94
|
+
})
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
### Production Build Configuration
|
|
98
|
+
|
|
99
|
+
```typescript
|
|
100
|
+
export default defineConfig({
|
|
101
|
+
plugins: [
|
|
102
|
+
playcademy({
|
|
103
|
+
export: {
|
|
104
|
+
autoZip: true, // Creates .playcademy/{project-name}.zip
|
|
105
|
+
},
|
|
106
|
+
}),
|
|
107
|
+
],
|
|
108
|
+
})
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
### Custom Sandbox Configuration
|
|
112
|
+
|
|
113
|
+
```typescript
|
|
114
|
+
export default defineConfig({
|
|
115
|
+
plugins: [
|
|
116
|
+
playcademy({
|
|
117
|
+
sandbox: {
|
|
118
|
+
autoStart: false, // Disable auto-start
|
|
119
|
+
url: 'http://localhost:8080/api', // Custom port
|
|
120
|
+
verbose: true, // Enable debug logs
|
|
121
|
+
},
|
|
39
122
|
}),
|
|
40
123
|
],
|
|
41
|
-
// ...other Vite config
|
|
42
124
|
})
|
|
43
125
|
```
|
|
44
126
|
|
|
45
|
-
##
|
|
127
|
+
## Plugin Options
|
|
128
|
+
|
|
129
|
+
### Export Options (`export`)
|
|
130
|
+
|
|
131
|
+
Configuration for manifest generation and build output:
|
|
132
|
+
|
|
133
|
+
| Option | Type | Default | Description |
|
|
134
|
+
| ------------ | ----------------------------- | -------------- | ------------------------------- |
|
|
135
|
+
| `bootMode` | `'iframe' \| 'module'` | `'iframe'` | How the game should be launched |
|
|
136
|
+
| `entryPoint` | `string` | `'index.html'` | Main HTML file for your game |
|
|
137
|
+
| `platform` | `'web' \| 'godot' \| 'unity'` | `'web'` | Game engine/platform type |
|
|
138
|
+
| `autoZip` | `boolean` | `false` | Create deployment zip archive |
|
|
139
|
+
| `styles` | `string[]` | `[]` | Additional CSS files to load |
|
|
140
|
+
|
|
141
|
+
### Sandbox Options (`sandbox`)
|
|
142
|
+
|
|
143
|
+
Configuration for the development sandbox server:
|
|
144
|
+
|
|
145
|
+
| Option | Type | Default | Description |
|
|
146
|
+
| ----------- | --------- | ----------------------------- | -------------------------------- |
|
|
147
|
+
| `autoStart` | `boolean` | `true` | Start sandbox during development |
|
|
148
|
+
| `url` | `string` | `'http://localhost:4321/api'` | Sandbox server URL |
|
|
149
|
+
| `verbose` | `boolean` | `false` | Enable verbose logging |
|
|
150
|
+
|
|
151
|
+
## Build Output
|
|
152
|
+
|
|
153
|
+
### Development Mode
|
|
154
|
+
|
|
155
|
+
During `bun dev`, the plugin:
|
|
156
|
+
|
|
157
|
+
- Starts the sandbox server (if enabled)
|
|
158
|
+
- Provides game API simulation
|
|
159
|
+
- Enables hot reload for game code
|
|
160
|
+
|
|
161
|
+
Console output:
|
|
162
|
+
|
|
163
|
+
```
|
|
164
|
+
VITE v6.3.5 ready in 500ms
|
|
165
|
+
|
|
166
|
+
➜ Local: http://localhost:5173/
|
|
167
|
+
➜ Network: use --host to expose
|
|
46
168
|
|
|
47
|
-
|
|
48
|
-
This file is created in your Vite build's output directory (`dist` by default). It contains metadata about your game, such as its entry point, boot mode, and engine type, which is used by the Playcademy platform.
|
|
169
|
+
PLAYCADEMY v1.2.3
|
|
49
170
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
171
|
+
➜ Game: my-game
|
|
172
|
+
➜ Sandbox: http://localhost:4321/api
|
|
173
|
+
```
|
|
53
174
|
|
|
54
|
-
|
|
55
|
-
The plugin defaults Vite's `base` configuration to `'./'`. This is necessary for games to correctly reference assets when deployed on the Playcademy platform. If you explicitly set a `base` path in your `vite.config.ts`, the plugin will respect your configuration and not override it.
|
|
175
|
+
### Production Build
|
|
56
176
|
|
|
57
|
-
|
|
177
|
+
During `bun run build`, the plugin:
|
|
58
178
|
|
|
59
|
-
|
|
179
|
+
- Generates `playcademy.manifest.json` in `dist/`
|
|
180
|
+
- Creates deployment zip (if `autoZip: true`)
|
|
181
|
+
- Optimizes build for platform deployment
|
|
60
182
|
|
|
61
|
-
|
|
183
|
+
Console output:
|
|
62
184
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
185
|
+
```
|
|
186
|
+
dist/index.html 2.45 kB │ gzip: 1.12 kB
|
|
187
|
+
dist/assets/index-Bj8fxu6c.js 135.24 kB │ gzip: 43.82 kB
|
|
66
188
|
|
|
67
|
-
|
|
189
|
+
[Playcademy]
|
|
190
|
+
playcademy.manifest.json 0.25 kB
|
|
191
|
+
.playcademy/my-game.zip 1,234.56 kB
|
|
192
|
+
```
|
|
68
193
|
|
|
69
|
-
|
|
70
|
-
- Default: `'index.html'`
|
|
71
|
-
- The main HTML file for your game.
|
|
194
|
+
## Generated Files
|
|
72
195
|
|
|
73
|
-
|
|
196
|
+
### Manifest File
|
|
74
197
|
|
|
75
|
-
|
|
76
|
-
- Default: `[]`
|
|
77
|
-
- An array of CSS file paths (relative to the project root) that should be loaded by the Playcademy platform.
|
|
198
|
+
The plugin generates `dist/playcademy.manifest.json`:
|
|
78
199
|
|
|
79
|
-
|
|
200
|
+
```json
|
|
201
|
+
{
|
|
202
|
+
"version": 1,
|
|
203
|
+
"slug": "my-game",
|
|
204
|
+
"displayName": "My Game",
|
|
205
|
+
"description": "An awesome Playcademy game",
|
|
206
|
+
"entryPoint": "index.html",
|
|
207
|
+
"bootMode": "iframe",
|
|
208
|
+
"platform": "web",
|
|
209
|
+
"styles": [],
|
|
210
|
+
"gameVersion": "1.0.0"
|
|
211
|
+
}
|
|
212
|
+
```
|
|
80
213
|
|
|
81
|
-
|
|
82
|
-
- Default: `'custom'`
|
|
83
|
-
- Specifies the game engine used.
|
|
214
|
+
### Deployment Archive
|
|
84
215
|
|
|
85
|
-
-
|
|
86
|
-
- Type: `boolean`
|
|
87
|
-
- Default: `false`
|
|
88
|
-
- Controls whether to automatically create a zip archive of the build output.
|
|
216
|
+
With `autoZip: true`, creates `.playcademy/{project-name}.zip` containing all build files ready for platform upload.
|
|
89
217
|
|
|
90
218
|
## Development
|
|
91
219
|
|
|
92
|
-
|
|
220
|
+
### Development Workflow
|
|
93
221
|
|
|
94
222
|
```bash
|
|
95
|
-
|
|
223
|
+
# Start the development environment from monorepo root
|
|
224
|
+
bun dev
|
|
225
|
+
|
|
226
|
+
# This starts all applications with proper port allocation:
|
|
227
|
+
# - Landing: http://localhost:5173
|
|
228
|
+
# - Hub: http://localhost:5174
|
|
229
|
+
# - Docs: http://localhost:5175
|
|
230
|
+
# - Blog: http://localhost:5176
|
|
231
|
+
# - Sandbox: http://localhost:4321
|
|
96
232
|
```
|
|
97
233
|
|
|
98
|
-
|
|
234
|
+
For package-specific development:
|
|
99
235
|
|
|
100
236
|
```bash
|
|
237
|
+
# Change to package directory
|
|
238
|
+
cd packages/vite-plugin
|
|
239
|
+
|
|
240
|
+
# Build the plugin
|
|
101
241
|
bun run build
|
|
242
|
+
|
|
243
|
+
# Publish to npm (requires permissions)
|
|
244
|
+
bun run pub
|
|
245
|
+
```
|
|
246
|
+
|
|
247
|
+
## Dependencies
|
|
248
|
+
|
|
249
|
+
### Runtime Dependencies
|
|
250
|
+
|
|
251
|
+
- **archiver**: Zip file creation for deployment packages
|
|
252
|
+
- **picocolors**: Terminal color output for logging
|
|
253
|
+
|
|
254
|
+
### Development Dependencies
|
|
255
|
+
|
|
256
|
+
- **@playcademy/sandbox**: Development sandbox server
|
|
257
|
+
- **@types/archiver**: TypeScript definitions for archiver
|
|
258
|
+
- **yocto-spinner**: Progress indicators for build operations
|
|
259
|
+
|
|
260
|
+
### Peer Dependencies
|
|
261
|
+
|
|
262
|
+
- **typescript**: TypeScript compiler (v5+)
|
|
263
|
+
|
|
264
|
+
## Common Use Cases
|
|
265
|
+
|
|
266
|
+
### Basic Web Game
|
|
267
|
+
|
|
268
|
+
```typescript
|
|
269
|
+
// Minimal configuration for most web games
|
|
270
|
+
export default defineConfig({
|
|
271
|
+
plugins: [playcademy()],
|
|
272
|
+
})
|
|
273
|
+
```
|
|
274
|
+
|
|
275
|
+
### Godot Export
|
|
276
|
+
|
|
277
|
+
```typescript
|
|
278
|
+
// Configuration for Godot HTML5 exports
|
|
279
|
+
export default defineConfig({
|
|
280
|
+
plugins: [
|
|
281
|
+
playcademy({
|
|
282
|
+
export: {
|
|
283
|
+
platform: 'godot',
|
|
284
|
+
entryPoint: 'game.html',
|
|
285
|
+
},
|
|
286
|
+
}),
|
|
287
|
+
],
|
|
288
|
+
})
|
|
289
|
+
```
|
|
290
|
+
|
|
291
|
+
### Production Deployment
|
|
292
|
+
|
|
293
|
+
```typescript
|
|
294
|
+
// Optimized for production builds
|
|
295
|
+
export default defineConfig(({ mode }) => ({
|
|
296
|
+
plugins: [
|
|
297
|
+
playcademy({
|
|
298
|
+
export: {
|
|
299
|
+
autoZip: mode === 'production',
|
|
300
|
+
},
|
|
301
|
+
sandbox: {
|
|
302
|
+
verbose: mode === 'development',
|
|
303
|
+
},
|
|
304
|
+
}),
|
|
305
|
+
],
|
|
306
|
+
}))
|
|
102
307
|
```
|
|
308
|
+
|
|
309
|
+
## Troubleshooting
|
|
310
|
+
|
|
311
|
+
### Common Issues
|
|
312
|
+
|
|
313
|
+
**Manifest not generated**
|
|
314
|
+
|
|
315
|
+
- Ensure plugin is properly configured in `vite.config.ts`
|
|
316
|
+
- Check for build errors in console output
|
|
317
|
+
- Verify the build completes successfully
|
|
318
|
+
|
|
319
|
+
**Zip file not created**
|
|
320
|
+
|
|
321
|
+
- Enable `autoZip: true` in export options
|
|
322
|
+
- Check that build completed without errors
|
|
323
|
+
- Look for zip in `.playcademy/` directory
|
|
324
|
+
|
|
325
|
+
### Debug Mode
|
|
326
|
+
|
|
327
|
+
Enable verbose logging for troubleshooting:
|
|
328
|
+
|
|
329
|
+
```typescript
|
|
330
|
+
playcademy({
|
|
331
|
+
sandbox: {
|
|
332
|
+
verbose: true,
|
|
333
|
+
},
|
|
334
|
+
})
|
|
335
|
+
```
|
|
336
|
+
|
|
337
|
+
## Related Packages
|
|
338
|
+
|
|
339
|
+
- [`@playcademy/sandbox`](../sandbox/): Development sandbox server
|
|
340
|
+
- [`@playcademy/data`](../data/): Platform data types and schemas
|
|
341
|
+
- [`@playcademy/sdk`](../sdk/): Game development SDK
|
|
342
|
+
- [`@playcademy/utils`](../utils/): Shared utility functions
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Playcademy Vite Plugin
|
|
3
|
+
*
|
|
4
|
+
* Provides:
|
|
5
|
+
* - Auto-starting sandbox server during development
|
|
6
|
+
* - Hijacking dev server to serve Playcademy loader environment
|
|
7
|
+
* - Build-time manifest generation and optional zip packaging
|
|
8
|
+
*/
|
|
9
|
+
import type { Plugin } from 'vite';
|
|
10
|
+
import type { PlaycademyPluginOptions } from './types';
|
|
11
|
+
export declare function playcademy(options?: PlaycademyPluginOptions): Plugin;
|