Skip to content

Instantly share code, notes, and snippets.

@garbles
Created August 7, 2017 20:50
Show Gist options
  • Save garbles/6c1aa38f853f2957e9c94b4907100f7e to your computer and use it in GitHub Desktop.
Save garbles/6c1aa38f853f2957e9c94b4907100f7e to your computer and use it in GitHub Desktop.
Use Phaser with Typescript + Webpack
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<title></title>
</head>
<body>
<div id="root"></div>
<script crossorigin src="//cdn.jsdelivr.net/npm/[email protected]/build/phaser.js"></script>
</body>
</html>
import Phaser = require('phaser'); // works!
/// <reference path="../node_modules/phaser-ce/typescript/phaser.d.ts" />
declare module 'phaser' {
export = Phaser;
}
declare module 'pixi' {
export = PIXI;
}
declare module 'p2' {
export = p2;
}
module.exports = {
// ...
externals: {
phaser: 'Phaser',
p2: 'p2',
pixi: 'PIXI',
},
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment