Skip to content

Commit

Permalink
Switch to Zopfli compression (home-assistant#744)
Browse files Browse the repository at this point in the history
* Switch to Zopfli compression

* Lint
  • Loading branch information
andrey-git authored and balloob committed Dec 23, 2017
1 parent 60ac82e commit b16bc88
Show file tree
Hide file tree
Showing 4 changed files with 104 additions and 50 deletions.
7 changes: 7 additions & 0 deletions gulp/tasks/compress.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
const gulp = require('gulp');
const zopfli = require('gulp-zopfli');

gulp.task('compress', () =>
gulp.src('{hass_frontend,hass_frontend_es5}/**/*{.js,.html,.ttf,.json}', { base: '.' })
.pipe(zopfli())
.pipe(gulp.dest('./')));
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
"gulp-uglify": "^3.0.0",
"gulp-util": "^3.0.8",
"gulp-vinyl-zip": "^2.1.0",
"gulp-zopfli": "^1.0.0",
"home-assistant-js-websocket": "^1.1.2",
"html-minifier": "^3.5.6",
"mdn-polyfills": "^5.5.0",
Expand Down
19 changes: 1 addition & 18 deletions script/build_frontend
Original file line number Diff line number Diff line change
Expand Up @@ -51,24 +51,7 @@ cp build-es5/service_worker.js $OUTPUT_DIR_ES5
BUILD_DEV=0 ./node_modules/.bin/gulp gen-service-worker
cp build/service_worker.js $OUTPUT_DIR


# GZIP frontend
cd $OUTPUT_DIR
gzip -f -n -k -9 \
*.html \
*.js \
./panels/*.html \
./translations/*.json \
./translations/*/*.json \
./fonts/roboto/*.ttf \
./fonts/robotomono/*.ttf
cd ..
cd $OUTPUT_DIR_ES5
gzip -f -n -k -9 \
*.html \
*.js \
./panels/*.html
cd ..
./node_modules/.bin/gulp compress

# Generate the __init__ file
echo "VERSION = '`git rev-parse HEAD`'" >> $OUTPUT_DIR/__init__.py
Expand Down
127 changes: 95 additions & 32 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -616,7 +616,7 @@ ansi-styles@~1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-1.0.0.tgz#cb102df1c56f5123eab8b67cd7b98027a0279178"

any-promise@^1.0.0:
any-promise@^1.0.0, any-promise@^1.1.0:
version "1.3.0"
resolved "https://registry.yarnpkg.com/any-promise/-/any-promise-1.3.0.tgz#abc6afeedcea52e809cdc0376aed3ce39635d17f"

Expand Down Expand Up @@ -1484,6 +1484,10 @@ block-stream@*:
dependencies:
inherits "~2.0.0"

bluebird@^2.9.25:
version "2.11.0"
resolved "https://registry.yarnpkg.com/bluebird/-/bluebird-2.11.0.tgz#534b9033c022c9579c56ba3b3e5a5caafbb650e1"

body-parser@1.18.2, body-parser@^1.17.2:
version "1.18.2"
resolved "https://registry.yarnpkg.com/body-parser/-/body-parser-1.18.2.tgz#87678a19d84b47d859b83199bd59bce222b10454"
Expand Down Expand Up @@ -1633,6 +1637,10 @@ bytes@3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/bytes/-/bytes-3.0.0.tgz#d32815404d689699f85a4ea4fa8755dd13a96048"

bytes@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/bytes/-/bytes-1.0.0.tgz#3569ede8ba34315fab99c3e92cb04c7220de1fa8"

caller-path@^0.1.0:
version "0.1.0"
resolved "https://registry.yarnpkg.com/caller-path/-/caller-path-0.1.0.tgz#94085ef63581ecd3daa92444a8fe94e82577751f"
Expand Down Expand Up @@ -1981,6 +1989,10 @@ commander@2.9.0, commander@2.9.x:
dependencies:
graceful-readlink ">= 1.0.0"

commander@^2.8.1:
version "2.12.2"
resolved "https://registry.yarnpkg.com/commander/-/commander-2.12.2.tgz#0f5946c427ed9ec0d91a46bb9def53e54650e555"

commondir@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/commondir/-/commondir-1.0.1.tgz#ddd800da0c66127393cca5950ea968a3aaf1253b"
Expand Down Expand Up @@ -2283,7 +2295,7 @@ deep-is@~0.1.3:
version "0.1.3"
resolved "https://registry.yarnpkg.com/deep-is/-/deep-is-0.1.3.tgz#b369d6fb5dbc13eecf524f91b070feedc357cf34"

defaults@^1.0.0:
defaults@^1.0.0, defaults@^1.0.2:
version "1.0.3"
resolved "https://registry.yarnpkg.com/defaults/-/defaults-1.0.3.tgz#c656051e9817d9ff08ed881477f3fe4019f3ef7d"
dependencies:
Expand Down Expand Up @@ -2367,6 +2379,10 @@ detect-indent@^4.0.0:
dependencies:
repeating "^2.0.0"

detect-libc@^1.0.2:
version "1.0.3"
resolved "https://registry.yarnpkg.com/detect-libc/-/detect-libc-1.0.3.tgz#fa137c4bd698edf55cd5cd02ac559f91a4c4ba9b"

detect-node@^2.0.3:
version "2.0.3"
resolved "https://registry.yarnpkg.com/detect-node/-/detect-node-2.0.3.tgz#a2033c09cc8e158d37748fbde7507832bd6ce127"
Expand Down Expand Up @@ -3816,7 +3832,7 @@ gulp-util@^2.2.14, gulp-util@^2.2.17, gulp-util@^2.2.20, gulp-util@~2.2.14:
through2 "^0.5.0"
vinyl "^0.2.1"

gulp-util@^3.0.0, gulp-util@^3.0.6, gulp-util@^3.0.8, gulp-util@~3.0.4:
gulp-util@^3.0.0, gulp-util@^3.0.4, gulp-util@^3.0.6, gulp-util@^3.0.8, gulp-util@~3.0.4:
version "3.0.8"
resolved "https://registry.yarnpkg.com/gulp-util/-/gulp-util-3.0.8.tgz#0054e1e744502e27c04c187c3ecc505dd54bbb4f"
dependencies:
Expand Down Expand Up @@ -3851,6 +3867,17 @@ gulp-vinyl-zip@^2.1.0:
yauzl "^2.2.1"
yazl "^2.2.1"

gulp-zopfli@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/gulp-zopfli/-/gulp-zopfli-1.0.0.tgz#63cc6e48d109373479273a7d6d5d97961e7f1658"
dependencies:
bytes "^1.0.0"
defaults "^1.0.2"
gulp-util "^3.0.4"
node-zopfli "^1.2.1"
stream-to-array "^2.0.2"
through2 "^0.6.3"

gulp@^3.9.1:
version "3.9.1"
resolved "https://registry.yarnpkg.com/gulp/-/gulp-3.9.1.tgz#571ce45928dd40af6514fc4011866016c13845b4"
Expand Down Expand Up @@ -3977,7 +4004,7 @@ has@^1.0.1:
dependencies:
function-bind "^1.0.2"

hawk@~3.1.3:
hawk@3.1.3, hawk@~3.1.3:
version "3.1.3"
resolved "https://registry.yarnpkg.com/hawk/-/hawk-3.1.3.tgz#078444bd7c1640b0fe540d2c9b73d59678e8e1c4"
dependencies:
Expand Down Expand Up @@ -5483,6 +5510,10 @@ mz@^2.4.0, mz@^2.6.0:
object-assign "^4.0.1"
thenify-all "^1.0.0"

nan@^2.0.0:
version "2.8.0"
resolved "https://registry.yarnpkg.com/nan/-/nan-2.8.0.tgz#ed715f3fe9de02b57a5e6252d90a96675e1f085a"

nan@^2.3.0:
version "2.6.2"
resolved "https://registry.yarnpkg.com/nan/-/nan-2.6.2.tgz#e4ff34e6c95fdfb5aecc08de6596f43605a7db45"
Expand Down Expand Up @@ -5540,10 +5571,36 @@ node-pre-gyp@^0.6.36:
tar "^2.2.1"
tar-pack "^3.4.0"

node-pre-gyp@^0.6.4:
version "0.6.39"
resolved "https://registry.yarnpkg.com/node-pre-gyp/-/node-pre-gyp-0.6.39.tgz#c00e96860b23c0e1420ac7befc5044e1d78d8649"
dependencies:
detect-libc "^1.0.2"
hawk "3.1.3"
mkdirp "^0.5.1"
nopt "^4.0.1"
npmlog "^4.0.2"
rc "^1.1.7"
request "2.81.0"
rimraf "^2.6.1"
semver "^5.3.0"
tar "^2.2.1"
tar-pack "^3.4.0"

node-status-codes@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/node-status-codes/-/node-status-codes-1.0.0.tgz#5ae5541d024645d32a58fcddc9ceecea7ae3ac2f"

node-zopfli@^1.2.1:
version "1.4.0"
resolved "https://registry.yarnpkg.com/node-zopfli/-/node-zopfli-1.4.0.tgz#51a974ed2221fcc1bb9dbed36682057fa4c1fa94"
dependencies:
bluebird "^2.9.25"
commander "^2.8.1"
defaults "^1.0.2"
nan "^2.0.0"
node-pre-gyp "^0.6.4"

nodegit-promise@~4.0.0:
version "4.0.0"
resolved "https://registry.yarnpkg.com/nodegit-promise/-/nodegit-promise-4.0.0.tgz#5722b184f2df7327161064a791d2e842c9167b34"
Expand Down Expand Up @@ -6639,6 +6696,33 @@ request@2.79.0:
tunnel-agent "~0.4.1"
uuid "^3.0.0"

request@2.81.0, request@^2.81.0:
version "2.81.0"
resolved "https://registry.yarnpkg.com/request/-/request-2.81.0.tgz#c6928946a0e06c5f8d6f8a9333469ffda46298a0"
dependencies:
aws-sign2 "~0.6.0"
aws4 "^1.2.1"
caseless "~0.12.0"
combined-stream "~1.0.5"
extend "~3.0.0"
forever-agent "~0.6.1"
form-data "~2.1.1"
har-validator "~4.2.1"
hawk "~3.1.3"
http-signature "~1.1.0"
is-typedarray "~1.0.0"
isstream "~0.1.2"
json-stringify-safe "~5.0.1"
mime-types "~2.1.7"
oauth-sign "~0.8.1"
performance-now "^0.2.0"
qs "~6.4.0"
safe-buffer "^5.0.1"
stringstream "~0.0.4"
tough-cookie "~2.3.0"
tunnel-agent "^0.6.0"
uuid "^3.0.0"

request@^2.53.0, request@^2.72.0:
version "2.83.0"
resolved "https://registry.yarnpkg.com/request/-/request-2.83.0.tgz#ca0b65da02ed62935887808e6f510381034e3356"
Expand Down Expand Up @@ -6666,33 +6750,6 @@ request@^2.53.0, request@^2.72.0:
tunnel-agent "^0.6.0"
uuid "^3.1.0"

request@^2.81.0:
version "2.81.0"
resolved "https://registry.yarnpkg.com/request/-/request-2.81.0.tgz#c6928946a0e06c5f8d6f8a9333469ffda46298a0"
dependencies:
aws-sign2 "~0.6.0"
aws4 "^1.2.1"
caseless "~0.12.0"
combined-stream "~1.0.5"
extend "~3.0.0"
forever-agent "~0.6.1"
form-data "~2.1.1"
har-validator "~4.2.1"
hawk "~3.1.3"
http-signature "~1.1.0"
is-typedarray "~1.0.0"
isstream "~0.1.2"
json-stringify-safe "~5.0.1"
mime-types "~2.1.7"
oauth-sign "~0.8.1"
performance-now "^0.2.0"
qs "~6.4.0"
safe-buffer "^5.0.1"
stringstream "~0.0.4"
tough-cookie "~2.3.0"
tunnel-agent "^0.6.0"
uuid "^3.0.0"

require-dir@^0.3.2:
version "0.3.2"
resolved "https://registry.yarnpkg.com/require-dir/-/require-dir-0.3.2.tgz#c1d5c75e9fbffde9f2e6b33e383db4f594b5a6a9"
Expand Down Expand Up @@ -7353,6 +7410,12 @@ stream-shift@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/stream-shift/-/stream-shift-1.0.0.tgz#d5c752825e5367e786f78e18e445ea223a155952"

stream-to-array@^2.0.2:
version "2.3.0"
resolved "https://registry.yarnpkg.com/stream-to-array/-/stream-to-array-2.3.0.tgz#bbf6b39f5f43ec30bc71babcb37557acecf34353"
dependencies:
any-promise "^1.1.0"

streamfilter@^1.0.5:
version "1.0.5"
resolved "https://registry.yarnpkg.com/streamfilter/-/streamfilter-1.0.5.tgz#87507111beb8e298451717b511cfed8f002abf53"
Expand Down Expand Up @@ -7666,7 +7729,7 @@ through2@^0.5.0:
readable-stream "~1.0.17"
xtend "~3.0.0"

through2@^0.6.0, through2@^0.6.1, through2@~0.6.3, through2@~0.6.5:
through2@^0.6.0, through2@^0.6.1, through2@^0.6.3, through2@~0.6.3, through2@~0.6.5:
version "0.6.5"
resolved "https://registry.yarnpkg.com/through2/-/through2-0.6.5.tgz#41ab9c67b29d57209071410e1d7a7a968cd3ad48"
dependencies:
Expand Down

0 comments on commit b16bc88

Please sign in to comment.