@playcademy/vite-plugin 0.0.1-beta.14 → 0.0.1-beta.15

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 CHANGED
@@ -1,137 +1,342 @@
1
1
  # @playcademy/vite-plugin
2
2
 
3
- A Vite plugin to generate a `playcademy.manifest.json` for Playcademy games and optionally create a zip archive of the build output.
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 bun
29
+ # Using Bun (recommended)
9
30
  bun add -D @playcademy/vite-plugin
10
31
 
11
- # Using pnpm
12
- pnpm add -D @playcademy/vite-plugin
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 npm
18
- npm install --save-dev @playcademy/vite-plugin
38
+ # Using pnpm
39
+ pnpm add -D @playcademy/vite-plugin
19
40
  ```
20
41
 
21
- ## Usage
42
+ ## Quick Start
22
43
 
23
- Add the plugin to your `vite.config.ts` or `vite.config.js`:
44
+ Add the plugin to your `vite.config.ts`:
24
45
 
25
46
  ```typescript
26
- // vite.config.ts
27
47
  import { defineConfig } from 'vite'
28
48
 
29
49
  import { playcademy } from '@playcademy/vite-plugin'
30
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
75
+ import { playcademy } from '@playcademy/vite-plugin'
76
+
31
77
  export default defineConfig({
32
78
  plugins: [
33
79
  playcademy({
34
80
  export: {
35
- // bootMode: 'iframe',
36
- // entryPoint: 'my-game.html',
37
- // styles: ['src/main.css'],
38
- // platform: 'web',
39
- // autoZip: true, // Set to true to enable zipping locally
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
40
86
  },
41
87
  sandbox: {
42
- // autoStart: true, // Auto-start sandbox during development
43
- // url: 'http://localhost:4321/api', // Custom sandbox URL
44
- // verbose: true, // Enable verbose logging from sandbox
88
+ autoStart: true, // Start sandbox automatically
89
+ url: 'http://localhost:4321/api', // Sandbox URL
90
+ verbose: false, // Enable debug logging
45
91
  },
46
92
  }),
47
93
  ],
48
- // ...other Vite config
49
94
  })
50
95
  ```
51
96
 
52
- ## What it does
97
+ ### Production Build Configuration
53
98
 
54
- 1. **Auto-starts Development Sandbox**:
55
- During development (`vite dev`), the plugin automatically starts a local Playcademy sandbox server that provides game APIs for testing. This allows you to develop your game locally with full API integration.
56
-
57
- 2. **Generates `playcademy.manifest.json`**:
58
- 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.
59
-
60
- 3. **Creates Output Zip Archive (Optional)**:
61
- If `autoZip` is enabled, the plugin will create a zip file named `{your-project-name}.zip` inside a `.playcademy` directory at the root of your project (e.g., `my-game/.playcademy/my-game.zip`).
62
- This archive contains all the contents of your build output directory and can be uploaded directly to the Playcademy platform.
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
+ ```
63
110
 
64
- 4. **Sets Vite `base` Configuration (if not set by user)**:
65
- 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.
111
+ ### Custom Sandbox Configuration
66
112
 
67
- ## Options (`PlaycademyPluginOptions`)
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
+ },
122
+ }),
123
+ ],
124
+ })
125
+ ```
68
126
 
69
- The `playcademy()` plugin accepts an optional options object with two main namespaces:
127
+ ## Plugin Options
70
128
 
71
129
  ### Export Options (`export`)
72
130
 
73
131
  Configuration for manifest generation and build output:
74
132
 
75
- - **`bootMode`**:
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 |
76
140
 
77
- - Type: `'iframe' | 'module'`
78
- - Default: `'iframe'`
79
- - Specifies how the game should be launched.
141
+ ### Sandbox Options (`sandbox`)
80
142
 
81
- - **`entryPoint`**:
143
+ Configuration for the development sandbox server:
82
144
 
83
- - Type: `string`
84
- - Default: `'index.html'`
85
- - The main HTML file for your game.
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 |
86
150
 
87
- - **`styles`**:
151
+ ## Build Output
88
152
 
89
- - Type: `string[]`
90
- - Default: `[]`
91
- - An array of CSS file paths (relative to the project root) that should be loaded by the Playcademy platform.
153
+ ### Development Mode
92
154
 
93
- - **`platform`**:
155
+ During `bun dev`, the plugin:
94
156
 
95
- - Type: `'web' | 'godot' | 'unity'`
96
- - Default: `'web'`
97
- - Specifies the game engine used.
157
+ - Starts the sandbox server (if enabled)
158
+ - Provides game API simulation
159
+ - Enables hot reload for game code
98
160
 
99
- - **`autoZip`**:
100
- - Type: `boolean`
101
- - Default: `false`
102
- - Controls whether to automatically create a zip archive of the build output.
161
+ Console output:
103
162
 
104
- ### Sandbox Options (`sandbox`)
163
+ ```
164
+ VITE v6.3.5 ready in 500ms
105
165
 
106
- Configuration for the development sandbox server:
166
+ ➜ Local: http://localhost:5173/
167
+ ➜ Network: use --host to expose
168
+
169
+ PLAYCADEMY v1.2.3
170
+
171
+ ➜ Game: my-game
172
+ ➜ Sandbox: http://localhost:4321/api
173
+ ```
174
+
175
+ ### Production Build
107
176
 
108
- - **`autoStart`**:
177
+ During `bun run build`, the plugin:
109
178
 
110
- - Type: `boolean`
111
- - Default: `true`
112
- - Controls whether to automatically start the development sandbox during `vite dev`.
179
+ - Generates `playcademy.manifest.json` in `dist/`
180
+ - Creates deployment zip (if `autoZip: true`)
181
+ - Optimizes build for platform deployment
113
182
 
114
- - **`url`**:
183
+ Console output:
115
184
 
116
- - Type: `string`
117
- - Default: `'http://localhost:4321/api'`
118
- - The URL of the sandbox server to use (useful if you're running your own sandbox instance).
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
188
+
189
+ [Playcademy]
190
+ playcademy.manifest.json 0.25 kB
191
+ .playcademy/my-game.zip 1,234.56 kB
192
+ ```
193
+
194
+ ## Generated Files
195
+
196
+ ### Manifest File
197
+
198
+ The plugin generates `dist/playcademy.manifest.json`:
199
+
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
+ ```
119
213
 
120
- - **`verbose`**:
121
- - Type: `boolean`
122
- - Default: `false`
123
- - Enables verbose logging from the sandbox server and API handlers for debugging.
214
+ ### Deployment Archive
215
+
216
+ With `autoZip: true`, creates `.playcademy/{project-name}.zip` containing all build files ready for platform upload.
124
217
 
125
218
  ## Development
126
219
 
127
- To install dependencies for this package:
220
+ ### Development Workflow
128
221
 
129
222
  ```bash
130
- bun install
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
131
232
  ```
132
233
 
133
- To build the plugin:
234
+ For package-specific development:
134
235
 
135
236
  ```bash
237
+ # Change to package directory
238
+ cd packages/vite-plugin
239
+
240
+ # Build the plugin
136
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
+ })
137
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
+ }))
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