Compress legacy build and shared static files using Brotli (#23233)
* Revert "Remove Zopfli compression (#23157)" This reverts commitpull/23259/head4092f56ea5
. * Revert "Fix compression of hassio builds (#21869)" This reverts commitb69f0964c9
. * Compress legacy build and shared static files using Brotli
parent
e4fc21c991
commit
3552417b39
|
@ -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);
|
||||
|
||||
gulp.task("compress-app", compressAppBrotli);
|
||||
gulp.task("compress-hassio", compressHassioBrotli);
|
||||
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", gulp.parallel(compressAppModern, compressAppOther));
|
||||
gulp.task(
|
||||
"compress-hassio",
|
||||
gulp.parallel(compressHassioModern, compressHassioOther)
|
||||
);
|
||||
|
|
Loading…
Reference in New Issue