From 59c98b3f3dfb853cbe8b2c2e86d8462ff91e781c Mon Sep 17 00:00:00 2001 From: ludeeus Date: Tue, 3 Sep 2024 18:17:40 +0000 Subject: [PATCH] Fix compression of hassio builds --- build-scripts/gulp/compress.js | 32 +++++++++++++++++++++++--------- 1 file changed, 23 insertions(+), 9 deletions(-) diff --git a/build-scripts/gulp/compress.js b/build-scripts/gulp/compress.js index 1a6032c35c55..fa171c9154b5 100644 --- a/build-scripts/gulp/compress.js +++ b/build-scripts/gulp/compress.js @@ -15,23 +15,29 @@ const brotliOptions = { }; const zopfliOptions = { threshold: 150 }; -const compressDistBrotli = (rootDir, modernDir) => +const compressDistBrotli = (rootDir, modernDir, compressServiceWorker = true) => gulp - .src([`${modernDir}/**/${filesGlob}`, `${rootDir}/sw-modern.js`], { - base: rootDir, - }) + .src( + [ + `${modernDir}/**/${filesGlob}`, + compressServiceWorker ? `${rootDir}/sw-modern.js` : undefined, + ].filter(Boolean), + { + base: rootDir, + } + ) .pipe(brotli(brotliOptions)) .pipe(gulp.dest(rootDir)); -const compressDistZopfli = (rootDir, modernDir) => +const compressDistZopfli = (rootDir, modernDir, compressModern = false) => gulp .src( [ `${rootDir}/**/${filesGlob}`, - `!${modernDir}/**/${filesGlob}`, + compressModern ? undefined : `!${modernDir}/**/${filesGlob}`, `!${rootDir}/{sw-modern,service_worker}.js`, `${rootDir}/{authorize,onboarding}.html`, - ], + ].filter(Boolean), { base: rootDir } ) .pipe(zopfli(zopfliOptions)) @@ -40,12 +46,20 @@ const compressDistZopfli = (rootDir, modernDir) => const compressAppBrotli = () => compressDistBrotli(paths.app_output_root, paths.app_output_latest); const compressHassioBrotli = () => - compressDistBrotli(paths.hassio_output_root, paths.hassio_output_latest); + compressDistBrotli( + paths.hassio_output_root, + paths.hassio_output_latest, + false + ); const compressAppZopfli = () => compressDistZopfli(paths.app_output_root, paths.app_output_latest); const compressHassioZopfli = () => - compressDistZopfli(paths.hassio_output_root, paths.hassio_output_latest); + compressDistZopfli( + paths.hassio_output_root, + paths.hassio_output_latest, + true + ); gulp.task("compress-app", gulp.parallel(compressAppBrotli, compressAppZopfli)); gulp.task(