Skip to content

Commit

Permalink
Updated build scripts for webpack5 and Phaser 3.60
Browse files Browse the repository at this point in the history
  • Loading branch information
photonstorm committed Oct 24, 2023
1 parent 8aed1e5 commit 3df1e34
Show file tree
Hide file tree
Showing 10 changed files with 2,481 additions and 3,834 deletions.
5,576 changes: 2,113 additions & 3,463 deletions package-lock.json

Large diffs are not rendered by default.

29 changes: 16 additions & 13 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
{
"name": "phaser3-custom-build",
"version": "1.0.3",
"version": "2.0.0",
"description": "",
"main": "index.js",
"scripts": {
"build": "webpack --display-modules",
"build": "webpack",
"buildlog": "webpack --json --profile > webpack.build-log.json",
"buildsprite": "webpack --config webpack.config-sprite.js --display-modules",
"buildsprite": "webpack --config webpack.config-sprite.js",
"buildspritelog": "webpack --config webpack.config-sprite.js --json --profile > webpack.build-sprite-log.json",
"buildboth": "webpack --config webpack.config-both.js --display-modules",
"buildboth": "webpack --config webpack.config-both.js",
"buildbothlog": "webpack --config webpack.config-both.js --json --profile > webpack.build-both-log.json",
"buildspritesmall": "webpack --config webpack.config-sprite-small-loader.js --display-modules",
"buildspritesmall": "webpack --config webpack.config-sprite-small-loader.js",
"buildspritesmalllog": "webpack --config webpack.config-sprite-small-loader.js --json --profile > webpack.build-sprite-small-loader-log.json",
"buildfull": "webpack --config webpack.config-full.js --display-modules",
"buildfull": "webpack --config webpack.config-full.js",
"buildfulllog": "webpack --config webpack.config-full.js --json --profile > webpack.build-full-log.json",
"buildcore": "webpack --config webpack.config-core.js --display-modules",
"buildcore": "webpack --config webpack.config-core.js",
"buildcorelog": "webpack --config webpack.config-core.js --json --profile > webpack.build-core-log.json"
},
"repository": {
Expand All @@ -28,11 +28,14 @@
},
"homepage": "https://github.com/photonstorm/phaser3-custom-build#readme",
"dependencies": {
"clean-webpack-plugin": "^3.0.0",
"eventemitter3": "^4.0.7",
"phaser": "^3.50.0",
"uglifyjs-webpack-plugin": "^2.2.0",
"webpack": "^4.41.2",
"webpack-cli": "^3.3.10"
"clean-webpack-plugin": "^4.0.0",
"eventemitter3": "^5.0.1",
"phaser": "^3.60.0",
"terser-webpack-plugin": "^5.3.9",
"webpack": "^5.89.0",
"webpack-cli": "^5.1.4"
},
"devDependencies": {
"prettier": "3.0.3"
}
}
3 changes: 2 additions & 1 deletion phaser-core.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* @author Richard Davey <[email protected]>
* @copyright 2020 Photon Storm Ltd.
* @copyright 2023 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/

Expand All @@ -25,6 +25,7 @@ var Phaser = {
Display: { Masks: require('display/mask') },
DOM: require('dom'),
Events: require('events/EventEmitter'),
FX: require('fx'),
Game: require('core/Game'),
GameObjects: {
DisplayList: require('gameobjects/DisplayList'),
Expand Down
3 changes: 2 additions & 1 deletion phaser-full.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* @author Richard Davey <[email protected]>
* @copyright 2020 Photon Storm Ltd.
* @copyright 2023 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/

Expand Down Expand Up @@ -28,6 +28,7 @@ var Phaser = {
Display: require('display'),
DOM: require('dom'),
Events: require('events/index'),
FX: require('fx'),
Game: require('core/Game'),
GameObjects: require('gameobjects'),
Geom: require('geom'),
Expand Down
120 changes: 59 additions & 61 deletions webpack.config-both.js
Original file line number Diff line number Diff line change
@@ -1,72 +1,70 @@
'use strict';

const webpack = require('webpack');
const UglifyJSPlugin = require('uglifyjs-webpack-plugin');
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
const path = require('path');
const { CleanWebpackPlugin } = require("clean-webpack-plugin");
const path = require("path");
const TerserPlugin = require("terser-webpack-plugin");
const webpack = require("webpack");

module.exports = {
// mode: 'development',
mode: "production",

// mode: 'development',
mode: 'production',

entry: {
'phaser-custom': `./phaser-custom.js`,
'phaser-custom.min': './phaser-custom.js',
'phaser-custom-sprite': `./phaser-custom-sprite.js`,
'phaser-custom-sprite.min': './phaser-custom-sprite.js'
},

resolve: {
alias: {
'eventemitter3': path.resolve(__dirname, './node_modules/eventemitter3')
},
modules: [ 'node_modules/phaser/src' ]
},
entry: {
"phaser-custom": `./phaser-custom.js`,
"phaser-custom.min": "./phaser-custom.js",
"phaser-custom-sprite": `./phaser-custom-sprite.js`,
"phaser-custom-sprite.min": "./phaser-custom-sprite.js",
},

output: {
path: `${__dirname}/dist/`,
filename: '[name].js',
library: 'Phaser',
libraryTarget: 'umd',
sourceMapFilename: '[file].map',
devtoolModuleFilenameTemplate: 'webpack:///[resource-path]',
devtoolFallbackModuleFilenameTemplate: 'webpack:///[resource-path]?[hash]',
umdNamedDefine: true
},
resolve: {
alias: {
eventemitter3: path.resolve(
__dirname,
"./node_modules/eventemitter3",
),
},
modules: ["node_modules/phaser/src"],
},

performance: { hints: false },
output: {
path: `${__dirname}/dist/`,
filename: "[name].js",
library: "Phaser",
libraryTarget: "umd",
sourceMapFilename: "[file].map",
devtoolModuleFilenameTemplate: "webpack:///[resource-path]",
devtoolFallbackModuleFilenameTemplate:
"webpack:///[resource-path]?[hash]",
umdNamedDefine: true,
},

optimization: {
minimizer: [
new UglifyJSPlugin({
include: /\.min\.js$/,
parallel: true,
sourceMap: false,
uglifyOptions: {
compress: true,
ie8: false,
ecma: 5,
output: {comments: false},
warnings: false
},
warningsFilter: () => false
})
]
},
performance: { hints: false },

plugins: [
new webpack.DefinePlugin({
"typeof CANVAS_RENDERER": JSON.stringify(true),
"typeof WEBGL_RENDERER": JSON.stringify(true),
"typeof EXPERIMENTAL": JSON.stringify(false),
"typeof PLUGIN_CAMERA3D": JSON.stringify(false),
"typeof PLUGIN_FBINSTANT": JSON.stringify(false)
}),
optimization: {
minimizer: [
new TerserPlugin({
include: /\.min\.js$/,
terserOptions: {
output: {
comments: false,
},
},
}),
],
},

new CleanWebpackPlugin()
],
plugins: [
new webpack.DefinePlugin({
"typeof CANVAS_RENDERER": JSON.stringify(true),
"typeof WEBGL_RENDERER": JSON.stringify(true),
"typeof WEBGL_DEBUG": JSON.stringify(false),
"typeof EXPERIMENTAL": JSON.stringify(false),
"typeof PLUGIN_3D": JSON.stringify(false),
"typeof PLUGIN_CAMERA3D": JSON.stringify(false),
"typeof PLUGIN_FBINSTANT": JSON.stringify(false),
"typeof FEATURE_SOUND": JSON.stringify(true),
}),

devtool: 'source-map'
new CleanWebpackPlugin(),
],

devtool: "source-map",
};
116 changes: 57 additions & 59 deletions webpack.config-core.js
Original file line number Diff line number Diff line change
@@ -1,70 +1,68 @@
'use strict';

const webpack = require('webpack');
const UglifyJSPlugin = require('uglifyjs-webpack-plugin');
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
const path = require('path');
const { CleanWebpackPlugin } = require("clean-webpack-plugin");
const path = require("path");
const TerserPlugin = require("terser-webpack-plugin");
const webpack = require("webpack");

module.exports = {
// mode: 'development',
mode: "production",

// mode: 'development',
mode: 'production',

entry: {
'phaser-core': `./phaser-core.js`,
'phaser-core.min': './phaser-core.js'
},

resolve: {
alias: {
'eventemitter3': path.resolve(__dirname, './node_modules/eventemitter3')
},
modules: [ 'node_modules/phaser/src' ]
},
entry: {
"phaser-core": `./phaser-core.js`,
"phaser-core.min": "./phaser-core.js",
},

output: {
path: `${__dirname}/dist/`,
filename: '[name].js',
library: 'Phaser',
libraryTarget: 'umd',
sourceMapFilename: '[file].map',
devtoolModuleFilenameTemplate: 'webpack:///[resource-path]',
devtoolFallbackModuleFilenameTemplate: 'webpack:///[resource-path]?[hash]',
umdNamedDefine: true
},
resolve: {
alias: {
eventemitter3: path.resolve(
__dirname,
"./node_modules/eventemitter3",
),
},
modules: ["node_modules/phaser/src"],
},

performance: { hints: false },
output: {
path: `${__dirname}/dist/`,
filename: "[name].js",
library: "Phaser",
libraryTarget: "umd",
sourceMapFilename: "[file].map",
devtoolModuleFilenameTemplate: "webpack:///[resource-path]",
devtoolFallbackModuleFilenameTemplate:
"webpack:///[resource-path]?[hash]",
umdNamedDefine: true,
},

optimization: {
minimizer: [
new UglifyJSPlugin({
include: /\.min\.js$/,
parallel: true,
sourceMap: false,
uglifyOptions: {
compress: true,
ie8: false,
ecma: 5,
output: {comments: false},
warnings: false
},
warningsFilter: () => false
})
]
},
performance: { hints: false },

plugins: [
new webpack.DefinePlugin({
"typeof CANVAS_RENDERER": JSON.stringify(true),
"typeof WEBGL_RENDERER": JSON.stringify(true),
"typeof EXPERIMENTAL": JSON.stringify(false),
"typeof PLUGIN_CAMERA3D": JSON.stringify(false),
"typeof PLUGIN_FBINSTANT": JSON.stringify(false)
}),
optimization: {
minimizer: [
new TerserPlugin({
include: /\.min\.js$/,
terserOptions: {
output: {
comments: false,
},
},
}),
],
},

new CleanWebpackPlugin()
],
plugins: [
new webpack.DefinePlugin({
"typeof CANVAS_RENDERER": JSON.stringify(true),
"typeof WEBGL_RENDERER": JSON.stringify(true),
"typeof WEBGL_DEBUG": JSON.stringify(false),
"typeof EXPERIMENTAL": JSON.stringify(false),
"typeof PLUGIN_3D": JSON.stringify(false),
"typeof PLUGIN_CAMERA3D": JSON.stringify(false),
"typeof PLUGIN_FBINSTANT": JSON.stringify(false),
"typeof FEATURE_SOUND": JSON.stringify(true),
}),

devtool: 'source-map'
new CleanWebpackPlugin(),
],

devtool: "source-map",
};
Loading

0 comments on commit 3df1e34

Please sign in to comment.