From 32fdc7346fdab3eb61ed13a8a717851a9ffbc1d4 Mon Sep 17 00:00:00 2001 From: Paulie Date: Wed, 9 Aug 2023 17:35:21 +0200 Subject: [PATCH 1/3] Prettier auto update --- src/webpack/config/createConfig.js | 78 +++++++++++++++--------------- 1 file changed, 40 insertions(+), 38 deletions(-) diff --git a/src/webpack/config/createConfig.js b/src/webpack/config/createConfig.js index 5bacf23..885f3d8 100644 --- a/src/webpack/config/createConfig.js +++ b/src/webpack/config/createConfig.js @@ -9,7 +9,7 @@ const sanitizeFilename = require("sanitize-filename"); const WriteFilePlugin = require("../plugin/WriteFilePlugin"); const ZipFilesPlugin = require("../plugin/ZipFilesPlugin"); -const OptimizeBundleToFilesizePlugin = require('../plugin/OptimizeBundleToFilesizePlugin'); +const OptimizeBundleToFilesizePlugin = require("../plugin/OptimizeBundleToFilesizePlugin"); const CopyFilesPlugin = require("../plugin/CopyFilesPlugin"); const HtmlWebpackInlineSVGPlugin = require("../plugin/HtmlWebpackInlineSVGPlugin"); @@ -40,7 +40,7 @@ module.exports = function createConfig({ richmediarcFilepath, outputPath, - options: {mode = DevEnum.DEVELOPMENT, stats = false} = { + options: { mode = DevEnum.DEVELOPMENT, stats = false } = { mode: DevEnum.DEVELOPMENT, stats: false, }, @@ -132,7 +132,7 @@ module.exports = function createConfig({ loaderArray.push({ loader: "esbuild-loader", options: { - target: 'es2015' + target: "es2015", }, }); } @@ -271,7 +271,7 @@ module.exports = function createConfig({ // don't optimize images if optimizeToFileSize is set to true imageLoadersArray.push({ loader: path.resolve(path.join(__dirname, "../loader/ImageOptimizeLoader.js")), - options: {} + options: {}, }); } @@ -279,21 +279,20 @@ module.exports = function createConfig({ }, }, - { test: /\.(ttf|woff|woff2)$/, use: [ richmediarc.settings.fontsBase64 ? { - loader: "url-loader", - } + loader: "url-loader", + } : { - loader: "file-loader", - options: { - // name: `[name]${namedHashing}.[ext]`, - name: `${namedHashing}.[ext]`, + loader: "file-loader", + options: { + // name: `[name]${namedHashing}.[ext]`, + name: `${namedHashing}.[ext]`, + }, }, - }, { loader: path.resolve(path.join(__dirname, "../loader/RichmediaFontLoader.js")), options: { @@ -359,30 +358,32 @@ module.exports = function createConfig({ if (fs.existsSync(staticPath)) { config.plugins.push( new CopyFilesPlugin({ - fromPath: staticPath + fromPath: staticPath, }) ); } if (richmediarc.settings.type === "flashtalking") { - console.log('found flashtalking ad') + console.log("found flashtalking ad"); const outputString = `FT.manifest({ "filename": "index.html", "width": ${richmediarc.settings.size.width}, "height": ${richmediarc.settings.size.height}, "clickTagCount": 1 -});` +});`; - config.plugins.push(new WriteFilePlugin({ - filePath: './', - fileName: 'manifest.js', - content: outputString - })) + config.plugins.push( + new WriteFilePlugin({ + filePath: "./", + fileName: "manifest.js", + content: outputString, + }) + ); } if (richmediarc.settings.type === "adform") { - let clickTags = richmediarc.settings.clickTags || {clickTAG: "http://www.adform.com"}; + let clickTags = richmediarc.settings.clickTags || { clickTAG: "http://www.adform.com" }; let obj = { version: "1.0", title: richmediarc.settings.bundleName || bundleName, @@ -399,11 +400,13 @@ module.exports = function createConfig({ source: "index.html", }; - config.plugins.push(new WriteFilePlugin({ - filePath: './', - fileName: 'manifest.json', - content: JSON.stringify(obj, null, 2) - })) + config.plugins.push( + new WriteFilePlugin({ + filePath: "./", + fileName: "manifest.json", + content: JSON.stringify(obj, null, 2), + }) + ); } config.optimization = { @@ -428,19 +431,18 @@ module.exports = function createConfig({ } if (mode === DevEnum.PRODUCTION) { - config.plugins.push( - richmediarc.settings.optimizeToFileSize ? - new OptimizeBundleToFilesizePlugin({ - outputPath: path.join(outputPath, "../"), - filename: `${bundleName}.zip`, - maxFileSize: richmediarc.settings.maxFileSize * 1024, - lowestQuality: 60, - }) : - new ZipFilesPlugin({ - outputPath: path.join(outputPath, "../"), - filename: `${bundleName}.zip` - }) + richmediarc.settings.optimizeToFileSize + ? new OptimizeBundleToFilesizePlugin({ + outputPath: path.join(outputPath, "../"), + filename: `${bundleName}.zip`, + maxFileSize: richmediarc.settings.maxFileSize * 1024, + lowestQuality: 60, + }) + : new ZipFilesPlugin({ + outputPath: path.join(outputPath, "../"), + filename: `${bundleName}.zip`, + }) ); } From 87820e2904b4e13cd1022cffb01ac15f4762a0f1 Mon Sep 17 00:00:00 2001 From: Paulie Date: Wed, 9 Aug 2023 17:36:20 +0200 Subject: [PATCH 2/3] Add lowestImageQuality setting from config to OptimizeBundleToFilesizePlugin --- src/webpack/config/createConfig.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/webpack/config/createConfig.js b/src/webpack/config/createConfig.js index 885f3d8..ddd096e 100644 --- a/src/webpack/config/createConfig.js +++ b/src/webpack/config/createConfig.js @@ -437,7 +437,7 @@ module.exports = function createConfig({ outputPath: path.join(outputPath, "../"), filename: `${bundleName}.zip`, maxFileSize: richmediarc.settings.maxFileSize * 1024, - lowestQuality: 60, + lowestQuality: richmediarc.settings.lowestImageQuality ? richmediarc.settings.lowestImageQuality : 60, }) : new ZipFilesPlugin({ outputPath: path.join(outputPath, "../"), From 4ad267053c2bb188d6b6ee786aef6a27319cd6df Mon Sep 17 00:00:00 2001 From: Paulie Date: Wed, 9 Aug 2023 17:36:20 +0200 Subject: [PATCH 3/3] Add lowestImageQuality setting from config to OptimizeBundleToFilesizePlugin If you add lowestImageQuality to your settings and describe a quality percentage (default is 60) you can set the quality of the image compression lower or higher --- src/webpack/config/createConfig.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/webpack/config/createConfig.js b/src/webpack/config/createConfig.js index 885f3d8..ddd096e 100644 --- a/src/webpack/config/createConfig.js +++ b/src/webpack/config/createConfig.js @@ -437,7 +437,7 @@ module.exports = function createConfig({ outputPath: path.join(outputPath, "../"), filename: `${bundleName}.zip`, maxFileSize: richmediarc.settings.maxFileSize * 1024, - lowestQuality: 60, + lowestQuality: richmediarc.settings.lowestImageQuality ? richmediarc.settings.lowestImageQuality : 60, }) : new ZipFilesPlugin({ outputPath: path.join(outputPath, "../"),