From a509dde986e4d4ea02a5d9ce4c1bd1bd85e99047 Mon Sep 17 00:00:00 2001 From: Martin Pitt Date: Fri, 23 Jul 2021 07:39:58 +0200 Subject: [PATCH] Update terser-webpack-plugin Following our other projects. --- cockpit-starter-kit.spec.in | 2 +- package.json | 2 +- packit.yaml | 2 +- webpack.config.js | 13 ++++++++++++- 4 files changed, 15 insertions(+), 4 deletions(-) diff --git a/cockpit-starter-kit.spec.in b/cockpit-starter-kit.spec.in index 32520fd..49c06fe 100644 --- a/cockpit-starter-kit.spec.in +++ b/cockpit-starter-kit.spec.in @@ -28,7 +28,7 @@ find %{buildroot}%{_datadir}/cockpit/ -name '*.map' | xargs --no-run-if-empty rm %files %doc README.md -%license LICENSE dist/index.js.LICENSE.txt +%license LICENSE dist/index.js.LICENSE.txt.gz %{_datadir}/cockpit/* %{_datadir}/metainfo/* diff --git a/package.json b/package.json index 5480494..a36448f 100644 --- a/package.json +++ b/package.json @@ -43,7 +43,7 @@ "sizzle": "^2.3.3", "stdio": "^2.1.0", "string-replace-loader": "^3.0.0", - "terser-webpack-plugin": "^2.0.1", + "terser-webpack-plugin": "^5.1.4", "webpack": "^5.31.0", "webpack-cli": "^4.6.0" }, diff --git a/packit.yaml b/packit.yaml index 33ec1ab..1b0e37f 100644 --- a/packit.yaml +++ b/packit.yaml @@ -12,7 +12,7 @@ actions: create-archive: - make NODE_ENV=development NODE_OPTIONS=--max-old-space-size=500 # dummy LICENSE.txt, as terser did not run - - touch dist/index.js.LICENSE.txt + - touch dist/index.js.LICENSE.txt.gz - make dist-gzip # starter-kit.git has no release tags; your project can drop this once you have a release get-current-version: make print-version diff --git a/webpack.config.js b/webpack.config.js index 8b5aa1d..5f4737b 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -58,7 +58,18 @@ module.exports = { optimization: { minimize: production, - minimizer: [new TerserJSPlugin(), new CssMinimizerPlugin()], + minimizer: [ + new TerserJSPlugin({ + extractComments: { + condition: true, + filename: `[file].LICENSE.txt?query=[query]&filebase=[base]`, + banner(licenseFile) { + return `License information can be found in ${licenseFile}`; + }, + }, + }), + new CssMinimizerPlugin() + ], }, module: {