Skip to content

Commit ca13ff2

Browse files
bferguson3yandeu
andauthored
Fixes for webpack 5 and windows NPM (#5)
* Update enable3d, matter-js, phaser, poly-decomp, three, typescript and dev dependencies to highest possible versions. * fix for windows NPM * TS->JS injection fix for Electron or other resource packagers * Lock to ~ --------- Co-authored-by: yandeu <20306025+yandeu@users.noreply.github.com>
1 parent 0edd427 commit ca13ff2

File tree

7 files changed

+10665
-4456
lines changed

7 files changed

+10665
-4456
lines changed

package-lock.json

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

package.json

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,22 +36,24 @@
3636
},
3737
"license": "MIT",
3838
"dependencies": {
39-
"@enable3d/phaser-extension": "0.25.3",
40-
"matter-js": "0.19.0",
41-
"phaser": "3.55.2",
39+
"@enable3d/phaser-extension": "~0.25.3",
40+
"matter-js": "^0.19.0",
41+
"phaser": "~3.55.2",
4242
"poly-decomp": "^0.3.0",
43-
"three": "0.144.0"
43+
"three": "~0.144.0"
4444
},
4545
"devDependencies": {
4646
"serve": "^14.2.0",
4747
"ts-loader": "^9.4.2",
4848
"typescript": "^4.9.5",
49-
"webpack": "^5.75.0",
49+
"webpack": "^5.0.0",
5050
"webpack-cli": "^5.0.1",
51-
"webpack-merge": "^4.2.2",
51+
"webpack-merge": "^5.8.0",
52+
"webpack-obfuscator": "^3.5.1",
5253
"webpack-dev-server": "^4.11.1",
54+
"workbox-webpack-plugin": "^6.5.4",
5355
"clean-webpack-plugin": "^4.0.0",
54-
"copy-webpack-plugin": "^5.1.2",
56+
"copy-webpack-plugin": "^11.0.0",
5557
"html-webpack-plugin": "^5.5.0",
5658
"@types/node": "^18.14.0"
5759
}

pwa/service-worker.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/**
2+
* You should only modify this, if you know what you are doing.
3+
* This phaser template is using workbox (https://developers.google.com/web/tools/workbox/)
4+
* to precache all assets.
5+
* It uses the InjectManifest function from 'workbox-webpack-plugin' inside
6+
* webpack/webpack.common.js
7+
*/
8+
import { precacheAndRoute } from 'workbox-precaching/precacheAndRoute'
9+
10+
precacheAndRoute(self.__WB_MANIFEST);
11+

src/scripts/game.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,5 @@ const config: Phaser.Types.Core.GameConfig = {
1717
}
1818

1919
window.addEventListener('load', () => {
20-
enable3d(() => new Phaser.Game(config)).withPhysics('/assets/ammo')
20+
enable3d(() => new Phaser.Game(config)).withPhysics('assets/ammo')
2121
})

webpack/webpack.common.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ module.exports = {
1818
optimization: {
1919
splitChunks: {
2020
cacheGroups: {
21-
commons: {
21+
defaultVendors: {
2222
test: /[\\/]node_modules[\\/]/,
2323
name: 'vendors',
2424
chunks: 'all',
@@ -29,9 +29,11 @@ module.exports = {
2929
},
3030
plugins: [
3131
new HtmlWebpackPlugin({ gameName: 'My Phaser Game', template: 'src/index.html' }),
32-
new CopyWebpackPlugin([
32+
new CopyWebpackPlugin({
33+
patterns: [
3334
{ from: 'src/assets', to: 'assets' },
3435
{ from: 'src/favicon.ico', to: '' }
35-
])
36+
37+
]})
3638
]
3739
}

webpack/webpack.dev.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const merge = require('webpack-merge')
1+
const {merge} = require('webpack-merge')
22
const common = require('./webpack.common')
33

44
const dev = {

webpack/webpack.prod.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
const path = require('path')
2-
const merge = require('webpack-merge')
2+
const {merge} = require('webpack-merge')
33
const common = require('./webpack.common')
44
const { CleanWebpackPlugin } = require('clean-webpack-plugin')
55

0 commit comments

Comments
 (0)