{"id":13445680,"url":"https://github.com/phaserjs/template-webpack","last_synced_at":"2025-05-14T10:11:21.512Z","repository":{"id":37436303,"uuid":"98904874","full_name":"phaserjs/template-webpack","owner":"phaserjs","description":"A Phaser 3 project template that uses Webpack 5 for bundling","archived":false,"fork":false,"pushed_at":"2024-10-11T13:52:52.000Z","size":2617,"stargazers_count":1154,"open_issues_count":4,"forks_count":772,"subscribers_count":25,"default_branch":"main","last_synced_at":"2024-10-29T14:35:22.856Z","etag":null,"topics":["phaser","phaser3","phaserjs","webpack"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/phaserjs.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"photonstorm","patreon":"photonstorm"}},"created_at":"2017-07-31T15:39:58.000Z","updated_at":"2024-10-23T12:26:18.000Z","dependencies_parsed_at":"2023-02-18T05:30:37.368Z","dependency_job_id":"4cc7ac3f-8802-46fc-bcb9-d9fba400fb20","html_url":"https://github.com/phaserjs/template-webpack","commit_stats":{"total_commits":42,"total_committers":11,"mean_commits":"3.8181818181818183","dds":0.6428571428571428,"last_synced_commit":"36d4510d0c3e4446bb6c89dc9047c6cad8355b89"},"previous_names":["phaserjs/template-webpack","photonstorm/phaser3-project-template"],"tags_count":1,"template":true,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phaserjs%2Ftemplate-webpack","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phaserjs%2Ftemplate-webpack/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phaserjs%2Ftemplate-webpack/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phaserjs%2Ftemplate-webpack/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/phaserjs","download_url":"https://codeload.github.com/phaserjs/template-webpack/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247907470,"owners_count":21016429,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["phaser","phaser3","phaserjs","webpack"],"created_at":"2024-07-31T05:00:37.762Z","updated_at":"2025-05-14T10:11:21.490Z","avatar_url":"https://github.com/phaserjs.png","language":"JavaScript","funding_links":["https://github.com/sponsors/photonstorm","https://patreon.com/photonstorm"],"categories":["Libraries"],"sub_categories":["Game engine"],"readme":"# Phaser Webpack Template\n\nThis is a Phaser 3 project template that uses webpack for bundling. It supports hot-reloading for quick development workflow and includes scripts to generate production-ready builds.\n\n**[This Template is also available as a TypeScript version.](https://github.com/phaserjs/template-webpack-ts)**\n\n### Versions\n\nThis template has been updated for:\n\n- [Phaser 3.88.2](https://github.com/phaserjs/phaser)\n- [Webpack 5.99.6](https://github.com/webpack/webpack)\n\n![screenshot](screenshot.png)\n\n## Requirements\n\n[Node.js](https://nodejs.org) is required to install dependencies and run scripts via `npm`.\n\n## Available Commands\n\n| Command | Description |\n|---------|-------------|\n| `npm install` | Install project dependencies |\n| `npm run dev` | Launch a development web server |\n| `npm run build` | Create a production build in the `dist` folder |\n| `npm run dev-nolog` | Launch a development web server without sending anonymous data (see \"About log.js\" below) |\n| `npm run build-nolog` | Create a production build in the `dist` folder without sending anonymous data (see \"About log.js\" below) |\n\n## Writing Code\n\nAfter cloning the repo, run `npm install` from your project directory. Then, you can start the local development server by running `npm run dev`.\n\nThe local development server runs on `http://localhost:8080` by default. Please see the webpack documentation if you wish to change this, or add SSL support.\n\nOnce the server is running you can edit any of the files in the `src` folder. Webpack will automatically recompile your code and then reload the browser.\n\n## Template Project Structure\n\nWe have provided a default project structure to get you started. This is as follows:\n\n| Path                         | Description                                                |\n|------------------------------|------------------------------------------------------------|\n| `public/index.html`          | A basic HTML page to contain the game.                     |\n| `public/assets`              | Game sprites, audio, etc. Served directly at runtime.      |\n| `public/style.css`           | Global layout styles.                                      |\n| `src/main.js`                | Application bootstrap.                                     |\n| `src/game`                   | Folder containing the game code.                           |\n| `src/game/main.js`           | Game entry point: configures and starts the game.          |\n| `src/game/scenes`            | Folder with all Phaser game scenes.                        |\n\n\n## Handling Assets\n\nWebpack supports loading assets via JavaScript module `import` statements.\n\nThis template provides support for both embedding assets and also loading them from a static folder. To embed an asset, you can import it at the top of the JavaScript file you are using it in:\n\n```js\nimport logoImg from './assets/logo.png'\n```\n\nTo load static files such as audio files, videos, etc place them into the `public/assets` folder. Then you can use this path in the Loader calls within Phaser:\n\n```js\npreload ()\n{\n    //  This is an example of an imported bundled image.\n    //  Remember to import it at the top of this file\n    this.load.image('logo', logoImg);\n\n    //  This is an example of loading a static image\n    //  from the public/assets folder:\n    this.load.image('background', 'assets/bg.png');\n}\n```\n\nWhen you issue the `npm run build` command, all static assets are automatically copied to the `dist/assets` folder.\n\n## Deploying to Production\n\nAfter you run the `npm run build` command, your code will be built into a single bundle and saved to the `dist` folder, along with any other assets your project imported, or stored in the public assets folder.\n\nIn order to deploy your game, you will need to upload *all* of the contents of the `dist` folder to a public facing web server.\n\n## Customizing the Template\n\n### Babel\n\nYou 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.\n\n ```\n\"browsers\": [\n  \"\u003e0.25%\",\n  \"not ie 11\",\n  \"not op_mini all\"\n]\n ```\n\n### Webpack\n\nIf 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/config.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`. Please see the [Webpack documentation](https://webpack.js.org/) for more information.\n\n## About log.js\n\nIf you inspect our node scripts you will see there is a file called `log.js`. This file makes a single silent API call to a domain called `gryzor.co`. This domain is owned by Phaser Studio Inc. The domain name is a homage to one of our favorite retro games.\n\nWe send the following 3 pieces of data to this API: The name of the template being used (vue, react, etc). If the build was 'dev' or 'prod' and finally the version of Phaser being used.\n\nAt no point is any personal data collected or sent. We don't know about your project files, device, browser or anything else. Feel free to inspect the `log.js` file to confirm this.\n\nWhy do we do this? Because being open source means we have no visible metrics about which of our templates are being used. We work hard to maintain a large and diverse set of templates for Phaser developers and this is our small anonymous way to determine if that work is actually paying off, or not. In short, it helps us ensure we're building the tools for you.\n\nHowever, if you don't want to send any data, you can use these commands instead:\n\nDev:\n\n```bash\nnpm run dev-nolog\n```\n\nBuild:\n\n```bash\nnpm run build-nolog\n```\n\nOr, to disable the log entirely, simply delete the file `log.js` and remove the call to it in the `scripts` section of `package.json`:\n\nBefore:\n\n```json\n\"scripts\": {\n    \"dev\": \"node log.js dev \u0026 dev-template-script\",\n    \"build\": \"node log.js build \u0026 build-template-script\"\n},\n```\n\nAfter:\n\n```json\n\"scripts\": {\n    \"dev\": \"dev-template-script\",\n    \"build\": \"build-template-script\"\n},\n```\n\nEither of these will stop `log.js` from running. If you do decide to do this, please could you at least join our Discord and tell us which template you're using! Or send us a quick email. Either will be super-helpful, thank you.\n\n## Join the Phaser Community!\n\nWe love to see what developers like you create with Phaser! It really motivates us to keep improving. So please join our community and show-off your work 😄\n\n**Visit:** The [Phaser website](https://phaser.io) and follow on [Phaser Twitter](https://twitter.com/phaser_)\u003cbr /\u003e\n**Play:** Some of the amazing games [#madewithphaser](https://twitter.com/search?q=%23madewithphaser\u0026src=typed_query\u0026f=live)\u003cbr /\u003e\n**Learn:** [API Docs](https://newdocs.phaser.io), [Support Forum](https://phaser.discourse.group/) and [StackOverflow](https://stackoverflow.com/questions/tagged/phaser-framework)\u003cbr /\u003e\n**Discord:** Join us on [Discord](https://discord.gg/phaser)\u003cbr /\u003e\n**Code:** 2000+ [Examples](https://labs.phaser.io)\u003cbr /\u003e\n**Read:** The [Phaser World](https://phaser.io/community/newsletter) Newsletter\u003cbr /\u003e\n\nCreated by [Phaser Studio](mailto:support@phaser.io). Powered by coffee, anime, pixels and love.\n\nThe Phaser logo and characters are \u0026copy; 2011 - 2025 Phaser Studio Inc.\n\nAll rights reserved.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphaserjs%2Ftemplate-webpack","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fphaserjs%2Ftemplate-webpack","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphaserjs%2Ftemplate-webpack/lists"}