Skip to content

Commit 8f6da8d

Browse files
Migrate to webpack v5
1 parent 9e81b3a commit 8f6da8d

7 files changed

+3402
-5578
lines changed

Diff for: .vscode/settings.json

-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
11
{
22
"editor.formatOnSave": true,
3-
"editor.codeActionsOnSave": {
4-
"source.fixAll": true
5-
},
63
"eslint.validate": ["javascript", "javascriptreact", "typescript", "typescriptreact"]
74
}

Diff for: package-lock.json

+3,338-5,501
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: package.json

+42-43
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
{
22
"name": "pixi-typescript-boilerplate",
3-
"version": "3.0.0",
3+
"version": "4.0.0-beta.0",
44
"description": "pixi.js typescript boilerplate webpack",
55
"browserslist": "> 0.25%, not dead",
66
"scripts": {
77
"webpack": "webpack",
8-
"webpack-dev-server": "webpack-dev-server --hot --open",
9-
"build": "npx del-cli dist --force && npm run webpack -- --env.mode production",
10-
"dev": "npm run webpack-dev-server -- --env.mode development --watch",
8+
"webpack-dev-server": "webpack-dev-server ",
9+
"build": "npx del-cli dist --force && npm run webpack -- --env mode=production",
10+
"dev": "npm run webpack-dev-server -- --env mode=development",
1111
"test": "npx jest",
1212
"code-coverage": "jest --coverage",
1313
"prettier": "npx prettier",
@@ -19,58 +19,57 @@
1919
"author": "jkanchelov",
2020
"license": "MIT",
2121
"dependencies": {
22-
"core-js": "^3.6.5",
22+
"core-js": "^3.8.3",
2323
"pixi.js": "^5.3.7"
2424
},
2525
"devDependencies": {
26-
"@babel/core": "^7.11.6",
27-
"@babel/plugin-proposal-class-properties": "^7.10.4",
28-
"@babel/plugin-proposal-decorators": "^7.10.5",
29-
"@babel/plugin-transform-modules-commonjs": "^7.10.4",
30-
"@babel/plugin-transform-runtime": "^7.11.5",
31-
"@babel/preset-env": "^7.11.5",
32-
"@babel/preset-typescript": "^7.10.4",
33-
"@babel/runtime": "^7.11.2",
34-
"@types/copy-webpack-plugin": "^6.0.0",
35-
"@types/html-webpack-plugin": "^3.2.3",
36-
"@types/jest": "^26.0.14",
37-
"@types/mini-css-extract-plugin": "^0.9.1",
38-
"@types/node": "^14.11.8",
39-
"@types/optimize-css-assets-webpack-plugin": "^5.0.1",
40-
"@types/terser-webpack-plugin": "^4.2.0",
41-
"@types/webpack": "^4.41.22",
42-
"@types/webpack-dev-server": "^3.11.0",
26+
"@babel/core": "^7.12.13",
27+
"@babel/plugin-proposal-class-properties": "^7.12.13",
28+
"@babel/plugin-proposal-decorators": "^7.12.13",
29+
"@babel/plugin-transform-modules-commonjs": "^7.12.13",
30+
"@babel/plugin-transform-runtime": "^7.12.13",
31+
"@babel/preset-env": "^7.12.13",
32+
"@babel/preset-typescript": "^7.12.13",
33+
"@babel/runtime": "^7.12.13",
34+
"@types/copy-webpack-plugin": "^6.4.0",
35+
"@types/html-webpack-plugin": "^3.2.4",
36+
"@types/jest": "^26.0.20",
37+
"@types/mini-css-extract-plugin": "^1.2.2",
38+
"@types/node": "^14.14.25",
39+
"@types/optimize-css-assets-webpack-plugin": "^5.0.2",
40+
"@types/terser-webpack-plugin": "^5.0.2",
41+
"@types/webpack": "^4.41.26",
4342
"@types/webpack-merge": "^4.1.5",
44-
"@typescript-eslint/eslint-plugin": "^4.4.0",
45-
"@typescript-eslint/parser": "^4.4.0",
46-
"babel-loader": "^8.1.0",
43+
"@typescript-eslint/eslint-plugin": "^4.14.2",
44+
"@typescript-eslint/parser": "^4.14.2",
45+
"babel-loader": "^8.2.2",
4746
"babel-register": "^6.26.0",
48-
"copy-webpack-plugin": "^6.2.1",
49-
"css-loader": "^4.3.0",
47+
"copy-webpack-plugin": "^7.0.0",
48+
"css-loader": "^5.0.1",
5049
"del-cli": "^3.0.1",
51-
"eslint": "^7.11.0",
52-
"eslint-config-prettier": "^6.12.0",
50+
"eslint": "^7.19.0",
51+
"eslint-config-prettier": "^7.2.0",
5352
"eslint-loader": "^4.0.2",
54-
"eslint-plugin-prettier": "^3.1.4",
55-
"html-webpack-plugin": "^4.5.0",
56-
"husky": "^4.3.0",
53+
"eslint-plugin-prettier": "^3.3.1",
54+
"html-webpack-plugin": "^5.0.0",
55+
"husky": "^4.3.8",
5756
"identity-obj-proxy": "^3.0.0",
58-
"jest": "^26.5.3",
57+
"jest": "^26.6.3",
5958
"jest-canvas-mock": "^2.3.0",
6059
"jsdom": "^16.4.0",
61-
"mini-css-extract-plugin": "^1.0.0",
60+
"mini-css-extract-plugin": "^1.3.5",
6261
"optimize-css-assets-webpack-plugin": "^5.0.4",
6362
"prettier": "^2.2.1",
6463
"pretty-quick": "^3.1.0",
65-
"terser-webpack-plugin": "^4.2.3",
66-
"ts-jest": "^26.4.1",
67-
"ts-loader": "^8.0.4",
68-
"ts-node": "^9.0.0",
69-
"typescript": "^4.0.3",
70-
"webpack": "^4.44.2",
71-
"webpack-cli": "^3.3.12",
72-
"webpack-dev-server": "^3.11.0",
73-
"webpack-merge": "^5.2.0"
64+
"terser-webpack-plugin": "^5.1.1",
65+
"ts-jest": "^26.5.0",
66+
"ts-loader": "^8.0.14",
67+
"ts-node": "^9.1.1",
68+
"typescript": "^4.1.3",
69+
"webpack": "^5.20.2",
70+
"webpack-cli": "^4.5.0",
71+
"webpack-dev-server": "^4.0.0-beta.0",
72+
"webpack-merge": "^5.7.3"
7473
},
7574
"jest": {
7675
"transform": {

Diff for: src/index.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
import * as PIXI from "pixi.js";
2-
32
import "./style.css";
43

4+
declare const VERSION: string;
5+
56
const gameWidth = 800;
67
const gameHeight = 600;
78

9+
console.log(`Welcome from pixi-typescript-boilerplate ${VERSION}`);
10+
811
const app = new PIXI.Application({
912
backgroundColor: 0xd3d3d3,
1013
width: gameWidth,

Diff for: webpack.config.ts

+2-3
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,6 @@ module.exports = (env: { mode: "development" | "production" }) => {
2727
use: [
2828
{
2929
loader: MiniCssExtractPlugin.loader,
30-
options: {
31-
hmr: developmentMode,
32-
},
3330
},
3431
"css-loader",
3532
],
@@ -65,5 +62,7 @@ module.exports = (env: { mode: "development" | "production" }) => {
6562

6663
const mergedConfig = merge(config, envConfig);
6764

65+
console.log(mergedConfig);
66+
6867
return mergedConfig;
6968
};

Diff for: webpack.development.ts

+8-7
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,21 @@
11
import * as webpack from "webpack";
22
import * as path from "path";
33

4+
import fs from "fs";
45
import MiniCssExtractPlugin from "mini-css-extract-plugin";
56

7+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
8+
const pkg: any = JSON.parse(fs.readFileSync(path.join(__dirname, "package.json"), "utf-8"));
9+
610
module.exports = (env: { mode: "development" | "production" }) => {
7-
/** @type {import('webpack').Configuration} */
811
const devConfig = {
912
mode: env.mode,
1013

11-
devtool: "cheap-module-eval-source-map",
14+
devtool: "inline-source-map",
1215

1316
devServer: {
1417
host: "0.0.0.0",
1518
openPage: "http://localhost:8080/",
16-
clientLogLevel: "silent",
1719
},
1820

1921
module: {
@@ -34,8 +36,8 @@ module.exports = (env: { mode: "development" | "production" }) => {
3436

3537
output: {
3638
path: path.resolve(__dirname, "dist"),
37-
filename: "game.js",
38-
chunkFilename: "game-library.js",
39+
filename: "[name].js",
40+
chunkFilename: "[id].js",
3941
},
4042

4143
plugins: [
@@ -44,8 +46,7 @@ module.exports = (env: { mode: "development" | "production" }) => {
4446
}),
4547

4648
new webpack.DefinePlugin({
47-
PRODUCTION: JSON.stringify(false),
48-
VERSION: JSON.stringify("3.0.0"), // TODO Update from package.json
49+
VERSION: JSON.stringify(pkg.version + "r"), // TODO Update from package.json
4950
}),
5051
],
5152
};

Diff for: webpack.production.ts

+8-20
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
import * as path from "path";
22
import * as webpack from "webpack";
33

4+
import fs from "fs";
45
import MiniCssExtractPlugin from "mini-css-extract-plugin";
56
import OptimizeCssAssetsPlugin from "optimize-css-assets-webpack-plugin";
6-
import TerserPlugin from "terser-webpack-plugin";
7+
8+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
9+
const pkg: any = JSON.parse(fs.readFileSync(path.join(__dirname, "package.json"), "utf-8"));
710

811
module.exports = (env: { mode: "development" | "production" }) => {
912
return {
@@ -42,13 +45,13 @@ module.exports = (env: { mode: "development" | "production" }) => {
4245

4346
output: {
4447
path: path.resolve(__dirname, "dist"),
45-
filename: "game.[hash].js",
46-
chunkFilename: "game-library.[contenthash].js",
48+
filename: "game.[contenthash].js",
49+
chunkFilename: "game-libraries.[contenthash].js",
4750
},
4851

4952
plugins: [
5053
new MiniCssExtractPlugin({
51-
filename: "[name].[hash].css",
54+
filename: "[name].[contenthash].css",
5255
}),
5356

5457
new OptimizeCssAssetsPlugin({
@@ -61,25 +64,10 @@ module.exports = (env: { mode: "development" | "production" }) => {
6164
}),
6265

6366
new webpack.DefinePlugin({
64-
PRODUCTION: JSON.stringify(true),
65-
VERSION: JSON.stringify("3.0.0"), // TODO Update from package.json
67+
VERSION: JSON.stringify(pkg.version + "r"), // TODO Update from package.json
6668
}),
6769

6870
new webpack.ProgressPlugin(),
6971
],
70-
71-
optimization: {
72-
minimize: true,
73-
minimizer: [
74-
new TerserPlugin({
75-
terserOptions: {
76-
mangle: true,
77-
toplevel: true,
78-
keep_classnames: false,
79-
keep_fnames: true,
80-
},
81-
}),
82-
],
83-
},
8472
};
8573
};

0 commit comments

Comments
 (0)