A high-performance, strictly-typed boilerplate designed for creating single-file playable ads using Phaser 3, Vite, and TypeScript.
The core of this project is a specialized build pipeline designed for the AdTech industry. Most ad networks (e.g., AppLovin, IronSource, Unity Ads) require playable ads to be delivered as a single index.html file where all assets (images, sounds, and code) are inlined.
This repository showcases a workflow that allows developers to:
- Use modern TypeScript and ESLint (Flat Config) for robust development.
- Maintain a modular architecture (Scenes, Classes, Plugins).
- Compile the entire project into a single, lightweight HTML file optimized for ad network requirements.
- Single-File Bundling: Automated pipeline to inline all assets (via Base64 encoding) into one standalone HTML file.
- Strict TypeScript Implementation: Full type safety across Phaser scenes and custom third-party plugins.
- Modern ESLint (v9+): Enforces explicit type definitions and prevents "any" leaks, ensuring high-quality, maintainable code.
| Technology | Purpose |
|---|---|
| Phaser 3 | Core game engine for high-performance 2D rendering. |
| TypeScript | Strict typing for scalable and bug-free game logic. |
| Vite | Lightning-fast development server and bundling engine. |
| ESLint | Modern Flat Config system for code quality and style. |
To maintain the "Single File" requirement while keeping file sizes low:
-
All images are processed through Vite's asset pipeline.
-
Small assets are automatically converted to Base64 URIs.
-
Texture Atlases are used to reduce the number of individual image declarations.
To maintain the "Single File" requirement while keeping file sizes low:
-
All images are processed through Vite's asset pipeline.
-
Small assets are automatically converted to Base64 URIs.
-
Texture Atlases are used to reduce the number of individual image declarations.
-
Install Dependencies:
npm install
-
Start Development Server:
npm run dev
-
Lint Project:
npm run lint
-
Build Single-File Ad:
npm run build
The output will be generated in the /dist folder as a standalone HTML file.
The included "Bank Robber" mini-game serves as a technical demonstration of the framework's capabilities:
-
Dynamic Scaling: Elements adjust based on custom getScale logic to fit any screen aspect ratio.
-
Gesture Control: Smooth character swapping via the Swipe plugin integration.
-
Tween Animations: High-quality feedback and "juice" using Phaser's internal tween engine.