├── .github └── workflows │ └── main.yml ├── .gitignore ├── LICENSE ├── README.md ├── assets ├── gasp.mp3 └── particle.png ├── favicon.svg ├── index.html ├── package.json ├── src ├── main.ts ├── menu-scene.ts └── style.css ├── tsconfig.json └── vite.config.js /.github/workflows/main.yml: -------------------------------------------------------------------------------- 1 | # This is a basic workflow to help you get started with Actions 2 | 3 | name: CI 4 | 5 | # Controls when the action will run. 6 | on: 7 | # Triggers the workflow on push or pull request events but only for the main branch 8 | push: 9 | branches: [ main ] 10 | pull_request: 11 | branches: [ main ] 12 | 13 | # Allows you to run this workflow manually from the Actions tab 14 | workflow_dispatch: 15 | 16 | # A workflow run is made up of one or more jobs that can run sequentially or in parallel 17 | jobs: 18 | # This workflow contains a single job called "build" 19 | build: 20 | # The type of runner that the job will run on 21 | runs-on: ubuntu-latest 22 | 23 | # Steps represent a sequence of tasks that will be executed as part of the job 24 | steps: 25 | # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it 26 | - uses: actions/checkout@v2 27 | 28 | # Runs a single command using the runners shell 29 | - name: npm install 30 | run: npm install 31 | 32 | # Runs a set of commands using the runners shell 33 | - name: npm run build 34 | run: npm run build 35 | 36 | - name: Deploy 🚀 37 | uses: JamesIves/github-pages-deploy-action@4.1.1 38 | with: 39 | branch: gh-pages # The branch the action should deploy to. 40 | folder: dist # The folder the action should deploy. 41 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | .DS_Store 3 | dist 4 | dist-ssr 5 | *.local 6 | package-lock.json -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2021 Yuval Greenfield 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## See this template in action 2 | See it live at https://ubershmekel.github.io/vite-phaser-ts-starter/ 3 | 4 | ## Get Started 5 | This is an example template. To try it out do the following: 6 | 7 | 1. Clone this repo 8 | 1. Run `npm install` 9 | 1. Run `npm run dev` 10 | 1. You should see a URL where your game shows up 11 | 12 | ``` 13 | { 14 | "scripts": { 15 | "dev": "vite", // start dev server 16 | "build": "vite build", // build for production 17 | "serve": "vite preview" // locally preview production build 18 | } 19 | } 20 | ``` 21 | 22 | Btw the live demo gets built by the github action at `.github/workflows/main.yml`. 23 | 24 | ## Why this tech stack 25 | 26 | I looked at quite a few web game frameworks. I settled on this setup because: 27 | 28 | * Phaser is the most prominent web game framework, with a lot of examples for pretty much every scenario. 29 | * Typescript lets me auto-complete everything and makes sure I avoid silly typo bugs. 30 | * Vite is much faster and simpler than Rollup and Webpack. I practically didn't have to do anything to get Phaser to work here, there's no complicated config file. The development-build-refresh cycle seems instant. It's fast enough that I never felt the need to measure it. Vite was built by evanw@ the person that built Vue.js. 31 | -------------------------------------------------------------------------------- /assets/gasp.mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ubershmekel/vite-phaser-ts-starter/2d9f7d7d1394e736dc8c59750ae8bec6cadd96e3/assets/gasp.mp3 -------------------------------------------------------------------------------- /assets/particle.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ubershmekel/vite-phaser-ts-starter/2d9f7d7d1394e736dc8c59750ae8bec6cadd96e3/assets/particle.png -------------------------------------------------------------------------------- /favicon.svg: -------------------------------------------------------------------------------- 1 | 16 | -------------------------------------------------------------------------------- /index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 | 5 | 6 | 7 |This is an example of setting up a Phaser, TypeScript, Vite game. See source on github.
12 |