Skip to content

Commit 6cdabee

Browse files
committed
Update template's packages to the latest versions (Webpack, Typescript, Phaser, Howler, etc)
1 parent 644a234 commit 6cdabee

File tree

9 files changed

+55
-73
lines changed

9 files changed

+55
-73
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@
33
dist/
44
node_modules/
55
.idea/
6+
package-lock.json

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
# Phaser.io CE 2.9.4, Howler.js 2.0.7, TypeScript and Webpack 3.10.0, play nice together.
1+
# Phaser.io CE 2.12.0, Howler.js 2.1.2, TypeScript and Webpack 4.3, play nice together.
22
#### A bootstrap project to create games with Phaser.io, Howler.js, TypeScript and Webpack.
33

44
## Features
55
- Uses the latest Phaser CE
66
- Uses Howler (an awesome audio library) - can be easily removed if one does not use it
77
- TypeScript linter that checks TypeScript code for readability, maintainability, and functionality errors
8-
- Webpack ready
8+
- Webpack 4 ready
99
- Built-in commands to easily deploy code your code (minify, uglify, comments removal, etc)
1010
- Other awesome stuff!
1111

package.json

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
"version": "1.0.0",
44
"description": "A good place to get started with Phaser and TypeScript development",
55
"scripts": {
6-
"start": "webpack-dev-server --config webpack.dev.config.js -d --inline --hot --progress --no-info --port 8000",
7-
"build": "rimraf ./dist && webpack --config webpack.prod.config.js -p --progress",
6+
"start": "webpack-dev-server --config webpack.dev.config.js -d --inline --hot --progress --port 8000 --mode development",
7+
"build": "rimraf ./dist && webpack --config webpack.prod.config.js -p --progress --mode production",
88
"lint": "tslint src/**/*.ts",
99
"lint:fix": "npm run lint -- --fix"
1010
},
@@ -19,23 +19,24 @@
1919
"license": "MIT",
2020
"homepage": "https://github.com/numbofathma/phaser-typescript-webpack",
2121
"devDependencies": {
22-
"copy-webpack-plugin": "^3.0.1",
23-
"expose-loader": "^0.7.1",
24-
"html-webpack-plugin": "^2.29.0",
25-
"rimraf": "^2.5.4",
26-
"ts-loader": "^0.8.2",
27-
"tslint": "^5.8.0",
28-
"tslint-loader": "^3.5.3",
29-
"tslint-webpack-plugin": "^1.0.0",
30-
"typescript": "^2.6.2",
31-
"webpack": "^3.10.0",
32-
"webpack-dev-server": "^2.9.7",
33-
"webpack-obfuscator": "^0.13.0",
34-
"webpack-uglify-js-plugin": "^1.1.9"
22+
"copy-webpack-plugin": "^5.0.3",
23+
"expose-loader": "^0.7.5",
24+
"html-webpack-plugin": "^3.2.0",
25+
"rimraf": "^2.6.3",
26+
"ts-loader": "^5.4.5",
27+
"tslint": "^5.16.0",
28+
"tslint-loader": "^3.5.4",
29+
"tslint-webpack-plugin": "^2.0.4",
30+
"typescript": "^3.4.5",
31+
"uglifyjs-webpack-plugin": "^2.1.2",
32+
"webpack": "^4.30.0",
33+
"webpack-cli": "^3.3.1",
34+
"webpack-dev-server": "^3.3.1",
35+
"webpack-obfuscator": "^0.18.0"
3536
},
3637
"dependencies": {
37-
"@types/howler": "^2.0.5",
38-
"howler": "^2.0.7",
39-
"phaser-ce": "^2.9.4"
38+
"@types/howler": "^2.1.0",
39+
"howler": "^2.1.2",
40+
"phaser-ce": "^2.12.0"
4041
}
4142
}

src/app.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import 'pixi';
2-
import 'p2';
3-
import Phaser from 'phaser-ce';
1+
const PIXI = require('phaser-ce/build/custom/pixi');
2+
const p2 = require('phaser-ce/build/custom/p2');
3+
const Phaser = require('phaser-ce/build/custom/phaser-arcade-physics');
44

55
import {Config} from './config';
66

src/prefabs/mushroom.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import Phaser from 'phaser-ce';
1+
const Phaser = require('phaser-ce/build/custom/phaser-arcade-physics');
22

33
export class Mushroom extends Phaser.Sprite {
44
constructor(game: Phaser.Game, x: number, y: number) {

src/states/game.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,8 @@
1-
import 'pixi';
2-
import 'p2';
3-
import Phaser from 'phaser-ce';
4-
51
import {Sound} from '../helpers/sound';
62
import {Mushroom} from '../prefabs/mushroom';
73

84
export class Game extends Phaser.State {
9-
private mushroom: Phaser.Sprite;
5+
private mushroom: Mushroom;
106
private cursors: Phaser.CursorKeys;
117
private text: Phaser.BitmapText;
128
private spaceKey: Phaser.Key;

src/states/preload.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import 'pixi';
22
import 'p2';
33
import Phaser from 'phaser-ce';
4+
45
import { Sound } from '../helpers/sound';
56

67
export class Preload extends Phaser.State {

webpack.dev.config.js

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
const path = require('path');
22

3-
const webpack = require('webpack');
43
const HtmlWebpackPlugin = require('html-webpack-plugin');
54
const TSLintPlugin = require('tslint-webpack-plugin');
65

@@ -9,11 +8,9 @@ const phaser = path.join(phaserModule, 'build/custom/phaser-arcade-physics.js');
98
const pixi = path.join(phaserModule, 'build/custom/pixi.js');
109
const p2 = path.join(phaserModule, 'build/custom/p2.js');
1110
const howler = path.join(__dirname, '/node_modules/howler/dist/howler.min.js');
12-
const vendorPackages = /phaser-ce|phaser-split|howler|pixi|p2/;
1311

1412
module.exports = {
1513
entry: {
16-
vendor: ['pixi', 'p2', 'phaser', 'howler'],
1714
app: [
1815
path.resolve(__dirname, 'src/app.ts')
1916
]
@@ -27,24 +24,18 @@ module.exports = {
2724
new TSLintPlugin({
2825
files: ['./src/**/*.ts']
2926
}),
30-
new webpack.optimize.CommonsChunkPlugin({
31-
name: 'vendor',
32-
minChunks: function(module, count) {
33-
return module.resource && vendorPackages.test(module.resource) && count >= 1;
34-
}
35-
}),
3627
new HtmlWebpackPlugin({
3728
template: './index.html',
3829
inject: 'body'
3930
})
4031
],
4132
module: {
42-
loaders: [
33+
rules: [
4334
{ test: /\.ts?$/, loader: 'ts-loader', exclude: '/node_modules/' },
44-
{ test: /pixi\.js/, use: ['expose-loader?PIXI'] },
45-
{ test: /phaser-arcade-physics\.js/, use: ['expose-loader?Phaser'] },
46-
{ test: /howler\.min\.js/, use: ['expose-loader?Howler'] },
47-
{ test: /p2\.js$/, use: ['expose-loader?p2'] }
35+
{ test: /pixi\.js/, loader: 'expose-loader?PIXI' },
36+
{ test: /phaser-arcade-physics\.js/, loader: 'expose-loader?Phaser' },
37+
{ test: /howler\.min\.js/, loader: 'expose-loader?Howler' },
38+
{ test: /p2\.js$/, loader: 'expose-loader?p2' }
4839
]
4940
},
5041
resolve: {

webpack.prod.config.js

Lines changed: 22 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
const path = require('path');
22

3-
const webpack = require('webpack');
43
const HtmlWebpackPlugin = require('html-webpack-plugin');
54
const CopyWebpackPlugin = require('copy-webpack-plugin');
65
const UglifyJsPlugin = require('uglifyjs-webpack-plugin');
@@ -11,14 +10,10 @@ const phaser = path.join(phaserModule, 'build/custom/phaser-arcade-physics.js');
1110
const pixi = path.join(phaserModule, 'build/custom/pixi.js');
1211
const p2 = path.join(phaserModule, 'build/custom/p2.js');
1312
const howler = path.join(__dirname, '/node_modules/howler/dist/howler.min.js');
14-
const vendorPackages = /phaser-ce|phaser-arcade-physics|howler|pixi|p2/;
1513

1614
module.exports = {
1715
entry: {
18-
vendor: ['pixi', 'p2', 'phaser', 'howler'],
19-
app: [
20-
path.resolve(__dirname, 'src/app.ts')
21-
]
16+
app: path.resolve(__dirname, 'src/app.ts')
2217
},
2318
output: {
2419
filename: '[name].bundle.js',
@@ -32,38 +27,35 @@ module.exports = {
3227
to: './assets'
3328
}
3429
]),
35-
new webpack.optimize.CommonsChunkPlugin({
36-
name: "vendor",
37-
minChunks: function (module, count) {
38-
return module.resource && vendorPackages.test(module.resource) && count >= 1;
39-
}
40-
}),
41-
new UglifyJsPlugin({
42-
uglifyOptions: {
43-
mangle: true,
44-
drop_console: true,
45-
minimize: true
46-
},
47-
output: {
48-
comments: false,
49-
beautify: false
50-
}
51-
}),
5230
new JavaScriptObfuscator({
5331
rotateUnicodeArray: true
5432
}, ['vendor.bundle.js']),
5533
new HtmlWebpackPlugin({
5634
template: './index.html',
57-
inject: 'body'
35+
inject: 'body',
5836
})
5937
],
38+
optimization: {
39+
splitChunks: {
40+
cacheGroups: {
41+
vendor: {
42+
test: /node_modules/,
43+
chunks: "initial",
44+
name: "vendor",
45+
priority: 10,
46+
enforce: true
47+
}
48+
}
49+
},
50+
minimizer: [new UglifyJsPlugin()],
51+
},
6052
module: {
61-
loaders: [
62-
{test: /\.ts?$/, loader: 'ts-loader', exclude: '/node_modules/'},
63-
{test: /pixi\.js/, use: ['expose-loader?PIXI']},
64-
{test: /phaser-arcade-physics\.js/, use: ['expose-loader?Phaser']},
65-
{test: /howler\.min\.js/, use: ['expose-loader?Howler']},
66-
{test: /p2\.js$/, use: ['expose-loader?p2']}
53+
rules: [
54+
{ test: /\.ts?$/, loader: 'ts-loader', exclude: '/node_modules/' },
55+
{ test: /pixi\.js/, loader: 'expose-loader?PIXI' },
56+
{ test: /phaser-arcade-physics\.js/, loader: 'expose-loader?Phaser' },
57+
{ test: /howler\.min\.js/, loader: 'expose-loader?Howler' },
58+
{ test: /p2\.js$/, loader: 'expose-loader?p2' }
6759
]
6860
},
6961
resolve: {

0 commit comments

Comments
 (0)