From 70e538701fa4bace0198e3b2790432aca21b05ff Mon Sep 17 00:00:00 2001 From: 902seanryan Date: Fri, 7 Jun 2024 11:30:23 -0300 Subject: [PATCH 1/3] update webpack terser options to drop console logs --- package-lock.json | 2 +- package.json | 2 +- webpack.config.js | 22 +++++++++++++++++----- 3 files changed, 19 insertions(+), 7 deletions(-) diff --git a/package-lock.json b/package-lock.json index 8c3465c..a81e040 100644 --- a/package-lock.json +++ b/package-lock.json @@ -26,7 +26,7 @@ "source-map-loader": "^1.0.0", "springroll": "^2.4.4", "style-loader": "^3.3.1", - "terser-webpack-plugin": "^5.3.6", + "terser-webpack-plugin": "^5.3.10", "webpack": "^5.75.0", "webpack-cli": "^4.10.0", "webpack-dev-server": "^4.11.1" diff --git a/package.json b/package.json index 4bdff4d..e4c2e2b 100644 --- a/package.json +++ b/package.json @@ -24,7 +24,7 @@ "source-map-loader": "^1.0.0", "springroll": "^2.4.4", "style-loader": "^3.3.1", - "terser-webpack-plugin": "^5.3.6", + "terser-webpack-plugin": "^5.3.10", "webpack": "^5.75.0", "webpack-cli": "^4.10.0", "webpack-dev-server": "^4.11.1" diff --git a/webpack.config.js b/webpack.config.js index b42e4ba..1ed8ac8 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -8,11 +8,12 @@ const ESLintPlugin = require('eslint-webpack-plugin'); const TerserPlugin = require('terser-webpack-plugin'); const deploy = path.join(__dirname, 'deploy'); -const isProduction = process.env.NODE_ENV == "production"; // keep the env param to be explicit, eslint disable should be removed when template is in use // eslint-disable-next-line no-unused-vars module.exports = (env) => { + const isProduction = !!env.production; + const plugins = [ new CleanPlugin.CleanWebpackPlugin(), new HtmlWebpackPlugin(HtmlConfig), @@ -47,10 +48,21 @@ module.exports = (env) => { }, optimization: { - minimizer: [new TerserPlugin({ - extractComments: true - })] - }, + minimize: true, + minimizer: [ + new TerserPlugin({ + + terserOptions: { + mangle: { + keep_fnames: isProduction ? false : true, + }, + compress: { + drop_console: isProduction ? ['log', 'info']: false, + }, + }, + }), + ], + }, plugins, From 0540395132d16d3484beb430909f5dd75fbee9a2 Mon Sep 17 00:00:00 2001 From: 902seanryan Date: Fri, 7 Jun 2024 11:30:43 -0300 Subject: [PATCH 2/3] changelog --- CHANGELOG.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5be6e3a..b34de0b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,19 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [2.1.0] - unreleased + +### Changed + +- Pixi: added TerserPlugin options to webpack to drop `console.log` and `console.info` in production builds +- Pixi: added TerserPlugin options to webpack to maintain function names in debug builds + +- Phaser: added TerserPlugin options to webpack to drop `console.log` and `console.info` in production builds +- Phaser: added TerserPlugin options to webpack to maintain function names in debug builds + +- CreateJS: added TerserPlugin options to webpack to drop `console.log` and `console.info` in production builds +- CreateJS: added TerserPlugin options to webpack to maintain function names in debug builds + ## [2.0.0] - 2024-05-09 ### Changed From d275d94a219a80dd8ec51003f6f52cf80315204a Mon Sep 17 00:00:00 2001 From: 902seanryan Date: Tue, 11 Jun 2024 09:59:36 -0300 Subject: [PATCH 3/3] changelog and version update --- CHANGELOG.md | 2 +- package-lock.json | 4 ++-- package.json | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b34de0b..719b6be 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,7 +5,7 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). -## [2.1.0] - unreleased +## [2.0.1] - unreleased ### Changed diff --git a/package-lock.json b/package-lock.json index a81e040..46ca48a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "springroll-seed", - "version": "2.0.0", + "version": "2.0.1", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "springroll-seed", - "version": "2.0.0", + "version": "2.0.1", "license": "ISC", "dependencies": { "phaser": "^3.80.1", diff --git a/package.json b/package.json index e4c2e2b..a700a0e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "springroll-seed", - "version": "2.0.0", + "version": "2.0.1", "description": "", "main": "index.js", "scripts": {