Skip to content

Commit 9ae0063

Browse files
committed
update to work with webpack v5
1 parent ee6a051 commit 9ae0063

File tree

8 files changed

+106
-40
lines changed

8 files changed

+106
-40
lines changed

package-lock.json

Lines changed: 85 additions & 21 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,13 @@
2121
"eslint-webpack-plugin": "^3.2.0",
2222
"html-webpack-plugin": "^5.5.0",
2323
"mini-css-extract-plugin": "^2.6.1",
24+
"source-map-loader": "^1.0.0",
25+
"springroll": "^2.4.4",
2426
"style-loader": "^3.3.1",
27+
"terser-webpack-plugin": "^5.3.6",
2528
"webpack": "^5.75.0",
2629
"webpack-cli": "^4.10.0",
27-
"webpack-dev-server": "^4.11.1",
28-
"source-map-loader": "^1.0.0",
29-
"springroll": "^2.4.4",
30-
"uglifyjs-webpack-plugin": "^2.2.0"
30+
"webpack-dev-server": "^4.11.1"
3131
},
3232
"dependencies": {
3333
"phaser": "git+ssh://[email protected]:pbs/phaser.git#bugfix/182892591-cordova-file-retrieval-bug-latest-version",

src/SpringrollGame.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { Application, SafeScaleManager } from "springroll";
22
import { GAMEPLAY, SCENE } from "./constants";
33
import { TitleScene, GameScene } from "./scenes";
44
import { FactoryPlugin } from "./plugins";
5+
import Phaser from 'phaser';
56

67
class SpringrollGame {
78
constructor() {
@@ -14,7 +15,7 @@ class SpringrollGame {
1415
});
1516

1617
// Instance of a Springroll.SafeScaleManager.
17-
// This will be initialized after the Phaser.Game is booted.
18+
// This will be initialized after the Phaser.Game is ready.
1819
this.safeScale = undefined;
1920

2021
// Instance of a Phaser.Game.
@@ -54,8 +55,8 @@ class SpringrollGame {
5455
}
5556
});
5657

57-
// Listen for when the game is booted.
58-
this.game.events.once("boot", () => {
58+
// Listen for when the game is ready.
59+
this.game.events.once("ready", () => {
5960
// Create a Springroll.SafeScaleManager.
6061
this.safeScale = new SafeScaleManager({
6162
width: GAMEPLAY.WIDTH,
@@ -64,15 +65,15 @@ class SpringrollGame {
6465
safeHeight: GAMEPLAY.SAFE_HEIGHT,
6566
callback: this.onWindowResize.bind(this)
6667
});
67-
})
68+
});
6869

6970
// Add game scenes.
7071
this.game.scene.add(SCENE.GAME, GameScene);
7172
this.game.scene.add(SCENE.TITLE, TitleScene, true);
7273
}
7374
}
7475

75-
onApplicationPause(value, oldValue) {
76+
onApplicationPause(value) {
7677
if(value) {
7778
this.game.scene.pause(SCENE.GAME);
7879
}
@@ -81,7 +82,7 @@ class SpringrollGame {
8182
}
8283
}
8384

84-
onMasterVolumeChange(value, oldValue) {
85+
onMasterVolumeChange(value) {
8586
this.game.sound.volume = value;
8687
}
8788

src/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
import './styles.css';
22
import 'phaser';
33

4+
5+
// eslint-disable-next-line no-unused-vars
46
import { SpringrollGame } from './SpringrollGame';

src/plugins/factory-plugin.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import Phaser from 'phaser';
1+
import { Plugins } from 'phaser';
22
import { Ball } from '../gameobjects';
33

4-
export class FactoryPlugin extends Phaser.Plugins.BasePlugin
4+
export class FactoryPlugin extends Plugins.BasePlugin
55
{
66
constructor(pluginManager)
77
{

src/scenes/game-scene.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { GAMEPLAY } from '../constants';
2+
import { Scene } from 'phaser';
23

3-
export class GameScene extends Phaser.Scene
4+
export class GameScene extends Scene
45
{
56
preload()
67
{

src/scenes/title-scene.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ export class TitleScene extends Phaser.Scene
4141
springrollGame.safeScale.addEntity(this.textAnchor);
4242
}
4343

44-
startText_onPointerDown(pointer)
44+
startText_onPointerDown()
4545
{
4646
this.scene.start(SCENE.GAME);
4747
}

webpack.config.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ const MiniCssExtractPlugin = require('mini-css-extract-plugin');
44
const CopyPlugin = require('copy-webpack-plugin');
55
const HtmlConfig = require(path.join(__dirname, 'html.config'));
66
const CleanPlugin = require('clean-webpack-plugin');
7-
const UglifyJsPlugin = require('uglifyjs-webpack-plugin');
87
const ESLintPlugin = require('eslint-webpack-plugin');
8+
const TerserPlugin = require('terser-webpack-plugin');
99

1010
const deploy = path.join(__dirname, 'deploy');
1111
const isProduction = process.env.NODE_ENV == "production";
@@ -47,10 +47,8 @@ module.exports = (env) => {
4747
},
4848

4949
optimization: {
50-
minimizer: [new UglifyJsPlugin({
51-
uglifyOptions: {
52-
output: { comments: false }
53-
}
50+
minimizer: [new TerserPlugin({
51+
extractComments: true
5452
})]
5553
},
5654

0 commit comments

Comments
 (0)