Skip to content

Commit

Permalink
Compress legacy build and shared static files using Brotli (#23233)
Browse files Browse the repository at this point in the history
* Revert "Remove Zopfli compression (#23157)"

This reverts commit 4092f56.

* Revert "Fix compression of hassio builds (#21869)"

This reverts commit b69f096.

* Compress legacy build and shared static files using Brotli
  • Loading branch information
steverep authored Dec 11, 2024
1 parent e4fc21c commit 3552417
Showing 1 changed file with 30 additions and 17 deletions.
47 changes: 30 additions & 17 deletions build-scripts/gulp/compress.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,28 +13,41 @@ const brotliOptions = {
},
};

const compressDistBrotli = (rootDir, modernDir, compressServiceWorker = true) =>
const compressModern = (rootDir, modernDir) =>
gulp
.src([`${modernDir}/**/${filesGlob}`, `${rootDir}/sw-modern.js`], {
base: rootDir,
allowEmpty: true,
})
.pipe(brotli(brotliOptions))
.pipe(gulp.dest(rootDir));

const compressOther = (rootDir, modernDir) =>
gulp
.src(
[
`${modernDir}/**/${filesGlob}`,
compressServiceWorker ? `${rootDir}/sw-modern.js` : undefined,
].filter(Boolean),
{
base: rootDir,
}
`${rootDir}/**/${filesGlob}`,
`!${modernDir}/**/${filesGlob}`,
`!${rootDir}/{sw-modern,service_worker}.js`,
`${rootDir}/{authorize,onboarding}.html`,
],
{ base: rootDir, allowEmpty: true }
)
.pipe(brotli(brotliOptions))
.pipe(gulp.dest(rootDir));

const compressAppBrotli = () =>
compressDistBrotli(paths.app_output_root, paths.app_output_latest);
const compressHassioBrotli = () =>
compressDistBrotli(
paths.hassio_output_root,
paths.hassio_output_latest,
false
);
const compressAppModern = () =>
compressModern(paths.app_output_root, paths.app_output_latest);
const compressHassioModern = () =>
compressModern(paths.hassio_output_root, paths.hassio_output_latest);

const compressAppOther = () =>
compressOther(paths.app_output_root, paths.app_output_latest);
const compressHassioOther = () =>
compressOther(paths.hassio_output_root, paths.hassio_output_latest);

gulp.task("compress-app", compressAppBrotli);
gulp.task("compress-hassio", compressHassioBrotli);
gulp.task("compress-app", gulp.parallel(compressAppModern, compressAppOther));
gulp.task(
"compress-hassio",
gulp.parallel(compressHassioModern, compressHassioOther)
);

0 comments on commit 3552417

Please sign in to comment.