From 5d61e9802318e17b548ba4ac4dd9389ffa2e90e5 Mon Sep 17 00:00:00 2001 From: Alex Lubbock Date: Wed, 4 Sep 2024 14:13:59 +0100 Subject: [PATCH] chore(deps): replace uglifyjs with terser (#90) new builtin module for webpack v5. --- thunorweb/webpack/package.json | 1 - thunorweb/webpack/webpack.config.js | 16 ++++++++-------- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/thunorweb/webpack/package.json b/thunorweb/webpack/package.json index 14897141..2fa65dcd 100644 --- a/thunorweb/webpack/package.json +++ b/thunorweb/webpack/package.json @@ -40,7 +40,6 @@ "sass": "^1.33.0", "sass-loader": "^16.0.0", "style-loader": "^4.0.0", - "uglifyjs-webpack-plugin": "^2.1.1", "webpack": "^5.94.0", "webpack-cli": "^5.0.0", "webpack-bundle-tracker": "^3.0.0" diff --git a/thunorweb/webpack/webpack.config.js b/thunorweb/webpack/webpack.config.js index c83ac396..54dd9606 100644 --- a/thunorweb/webpack/webpack.config.js +++ b/thunorweb/webpack/webpack.config.js @@ -1,10 +1,11 @@ const path = require("path"); +const fs = require('fs'); const BundleTracker = require("webpack-bundle-tracker"); -const UglifyJsPlugin = require("uglifyjs-webpack-plugin"); +const TerserPlugin = require("terser-webpack-plugin"); const MiniCssExtractPlugin = require("mini-css-extract-plugin"); const CssMinimizerPlugin = require("css-minimizer-webpack-plugin"); -const glob = require("glob"); const isDebug = (process.env.DJANGO_DEBUG === undefined ? false : process.env.DJANGO_DEBUG.toLowerCase() === "true"); +const faviconRoot = './thunor/favicons/' var config = { context: __dirname, @@ -12,7 +13,9 @@ var config = { mode: isDebug ? 'development' : 'production', entry: { - favicons: glob.sync("./thunor/favicons/*"), + favions: fs.readdirSync(faviconRoot, {withFileTypes: true}) + .filter(item => !item.isDirectory()) + .map(item => faviconRoot + item.name), app: ["expose-loader?exposes=pyHTS!./thunor/js/pyhts", "./thunor/css/fonts.css", "./thunor/css/pyhts.css"], @@ -116,12 +119,9 @@ var config = { }, optimization: { + minimize: !isDebug, minimizer: [ - new UglifyJsPlugin({ - cache: true, - parallel: true, - sourceMap: true // set to true if you want JS source maps - }), + new TerserPlugin(), new CssMinimizerPlugin({}) ] }