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
|
gulp
|
||||||
.src(
|
.src(
|
||||||
[
|
[
|
||||||
`${modernDir}/**/${filesGlob}`,
|
`${rootDir}/**/${filesGlob}`,
|
||||||
compressServiceWorker ? `${rootDir}/sw-modern.js` : undefined,
|
`!${modernDir}/**/${filesGlob}`,
|
||||||
].filter(Boolean),
|
`!${rootDir}/{sw-modern,service_worker}.js`,
|
||||||
{
|
`${rootDir}/{authorize,onboarding}.html`,
|
||||||
base: rootDir,
|
],
|
||||||
}
|
{ base: rootDir, allowEmpty: true }
|
||||||
)
|
)
|
||||||
.pipe(brotli(brotliOptions))
|
.pipe(brotli(brotliOptions))
|
||||||
.pipe(gulp.dest(rootDir));
|
.pipe(gulp.dest(rootDir));
|
||||||
|
|
||||||
const compressAppBrotli = () =>
|
const compressAppModern = () =>
|
||||||
compressDistBrotli(paths.app_output_root, paths.app_output_latest);
|
compressModern(paths.app_output_root, paths.app_output_latest);
|
||||||
const compressHassioBrotli = () =>
|
const compressHassioModern = () =>
|
||||||
compressDistBrotli(
|
compressModern(paths.hassio_output_root, paths.hassio_output_latest);
|
||||||
paths.hassio_output_root,
|
|
||||||
paths.hassio_output_latest,
|
|
||||||
false
|
|
||||||
);
|
|
||||||
|
|
||||||
gulp.task("compress-app", compressAppBrotli);
|
const compressAppOther = () =>
|
||||||
gulp.task("compress-hassio", compressHassioBrotli);
|
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