etgrieco / phaser3-wp-ts-template

Phaser 3 Boilerplate for Webpack 5 + Typescript

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Phaser 3 Webpack Project Template

(Forked from https://github.com/photonstorm/phaser3-project-template, with updates for Webpack 5 and support for TypeScript)

A Phaser 3 project template with ES6 support via Babel 8 and Webpack 5 that includes hot-reloading for development and production-ready builds.

This has been updated for Phaser 3.55.2 version and above.

Requirements

Latest version of yarn

Available Commands

Command Description
yarn install Install project dependencies
yarn start Build project and open web server running project
yarn build Builds code bundle with production settings (minification, uglification, etc..)

Writing Code

After cloning the repo, run yarn install from your project directory. Then, you can start the local development server by running npm start.

After starting the development server with npm start, you can edit any files in the src folder and webpack will automatically recompile and reload your server (available at http://localhost:8080 by default).

Customizing the Template

Babel

You can write modern ES6+ JavaScript and Babel will transpile it to a version of JavaScript that you want your project to support. The targeted browsers are set in the .babelrc file and the default currently targets all browsers with total usage over "0.25%" but excludes IE11 and Opera Mini.

"browsers": [
 ">0.25%",
 "not ie 11",
 "not op_mini all"
]

Webpack

If you want to customize your build, such as adding a new webpack loader or plugin (i.e. for loading CSS or fonts), you can modify the webpack/base.js file for cross-project changes, or you can modify and/or create new configuration files and target them in specific npm tasks inside of `package.json'.

Deploying Code

After you run the yarn build command, your code will be built into a single bundle located at dist/bundle.min.js along with any other assets you project depended.

If you put the contents of the dist folder in a publicly-accessible location (say something like http://mycoolserver.com), you should be able to open http://mycoolserver.com/index.html and play your game.

About

Phaser 3 Boilerplate for Webpack 5 + Typescript

License:MIT License


Languages

Language:JavaScript 70.9%Language:TypeScript 25.3%Language:HTML 3.8%