From d044ad94983233e0125cd6daf4be2377a905ab5e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joakim=20S=C3=B8rensen?= Date: Tue, 3 Sep 2024 16:05:11 +0200 Subject: [PATCH] Fix build by not using brotli compression yet (#783) * Include dummy sw files to fix build * No br support yet --- .github/workflows/TestBuild.yml | 2 -- script/build | 2 +- script/gulp/app.js | 12 ++++++------ script/gulp/compress.js | 16 ++++++++++++++++ 4 files changed, 23 insertions(+), 9 deletions(-) create mode 100644 script/gulp/compress.js diff --git a/.github/workflows/TestBuild.yml b/.github/workflows/TestBuild.yml index 6f642602d..a4e04e7f8 100644 --- a/.github/workflows/TestBuild.yml +++ b/.github/workflows/TestBuild.yml @@ -31,5 +31,3 @@ jobs: run: script/bootstrap - name: Build run: script/build - env: - IS_TEST: "true" diff --git a/script/build b/script/build index c36d16241..83d0bdb98 100755 --- a/script/build +++ b/script/build @@ -12,4 +12,4 @@ if [ ! -d "./node_modules" ]; then yarn install fi -./node_modules/.bin/gulp build-hacs \ No newline at end of file +NODE_OPTIONS=--max_old_space_size=6144 ./node_modules/.bin/gulp build-hacs \ No newline at end of file diff --git a/script/gulp/app.js b/script/gulp/app.js index 7a374f21b..5ff286dd9 100644 --- a/script/gulp/app.js +++ b/script/gulp/app.js @@ -1,7 +1,7 @@ import gulp from "gulp"; import env from "./env.cjs"; import "./clean.js"; -import "../../homeassistant-frontend/build-scripts/gulp/compress.js"; +import "./compress.js"; import "./entry-html.js"; import "./gather-static.js"; import "../../homeassistant-frontend/build-scripts/gulp/gen-icons-json.js"; @@ -20,12 +20,12 @@ gulp.task( "gen-dummy-icons-json", "gen-pages-app-dev", "build-locale-data", - "generate-translations" + "generate-translations", ), "build-translation-fingerprints", "copy-static-app", - "webpack-watch-app" - ) + "webpack-watch-app", + ), ); gulp.task( @@ -41,6 +41,6 @@ gulp.task( "webpack-prod-app", // Don't compress running tests ...(env.isTestBuild() ? [] : ["compress-app"]), - "gen-pages-app-prod" - ) + "gen-pages-app-prod", + ), ); diff --git a/script/gulp/compress.js b/script/gulp/compress.js new file mode 100644 index 000000000..1b47344d2 --- /dev/null +++ b/script/gulp/compress.js @@ -0,0 +1,16 @@ +// Tasks to compress +// Can not reuse HA compress.js untill min version is 2024.8 + +import gulp from "gulp"; +import zopfli from "gulp-zopfli-green"; +import paths from "./paths.cjs"; + +const zopfliOptions = { threshold: 150 }; + +const compressDist = (rootDir) => + gulp + .src([`${rootDir}/**/*.{js,json,css,svg,xml}`, `${rootDir}/{authorize,onboarding}.html`]) + .pipe(zopfli(zopfliOptions)) + .pipe(gulp.dest(rootDir)); + +gulp.task("compress-app", () => compressDist(paths.app_output_root));