Skip to content

Instantly share code, notes, and snippets.

@georgesboris
Last active June 22, 2017 16:09
Show Gist options
  • Save georgesboris/48e40307243248f2c8890e6f8ae00613 to your computer and use it in GitHub Desktop.
Save georgesboris/48e40307243248f2c8890e6f8ae00613 to your computer and use it in GitHub Desktop.
Phaser simple webpack setup

Using Phaser with Webpack

Using phaser with ES6, npm modules and whatnot is actually quite simple.

First, install the needed dependencies.

npm install -S expose-loader phaser-ce

Then import Phaser dependencies in the correct order.

import PIXI from 'expose-loader?PIXI!phaser-ce/build/custom/pixi.js';
import p2 from 'expose-loader?p2!phaser-ce/build/custom/p2.js';
import Phaser from 'expose-loader?Phaser!phaser-ce/build/custom/phaser-split.js';

let game = new Phaser.Game(800, 600, '', {
  preload: () => {},
  create: () => {},
  update: () => {}
});

That's it! Time to go crazy with all the new possibilities!

No additional configurations are needed in your webpack.config or anything. It just works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment