A shim to make Phaser HTML5 game engine from NPM work with Webpack, and build properly.
npm install phaser-shimA shim to make Phaser HTML5 game engine from NPM work with Webpack, and build properly.
> Phaser doesn't work with Webpack and require
``sh`
npm install phaser-shim --save
`js
// game.js
require('phaser-shim');
var game = new Phaser.Game(800, 600);
`
or ES6:
`js
// Game.js
import 'phaser-shim';
class Game extends Phaser.Game {
constructor (width, height) {
super(width, height);
}
}
`
`js
// game.js
import Game from './Game';
const game = new Game(800, 600);
`
or several per module:
`js`
import {Game, State} from 'phaser-shim';
or TypeScript:
`typescript
///
declare module 'phaser-shim' {
export = Phaser;
}
`
`js
// webpack.config.js
module: {
// ...
loaders: [{
loader: 'script',// script-loader
test: /(pixi|phaser).js/
}],
// ...
}
`
If you want to use other Phaser version (old or new) in yourself:
1. Fork this repo and git clone to local.
2. npm install with node v4.xnpm run build
3. to building dist/pixi and dist/phaserrequire
4. now you can or import your phaser-shim`
- @AnimaMundi