angular / closure-demo

MIT License
114 stars 27 forks source link

Bash script adjustments for Windows #15

Closed gregbown closed 7 years ago

gregbown commented 7 years ago

Thank you for the demo. I had to make a few tweaks to get it to work on windows so thought I would post my changes to size_report.sh I added printing the file sizes to a text file and moving the .gz and .brotli zone.js files to the dist directory

#!/usr/bin/env node
echo > build-report.txt
rootdir=dist

\# measure the sizes of scripts and move as needed
for script in dist/bundle.js node_modules/zone.js/dist/zone.min.js; do
  \# copy to temp
  cp $script $script.bak
  gzip -f $script
  mv $script.bak $script
  \# requires brotli.exe and environment path
  brotli --force --quality 10 --input $script --output $script.brotli
  brotlifilename=${script}.brotli
  gzfilename=${script}.gz
  brotlifilesize=$(du -b "$brotlifilename" | awk '{print $1}')
  gzfilesize=$(du -b "$gzfilename" | awk '{print $1}')
  echo ${brotlifilename} = ${brotlifilesize} >> build-report.txt
  echo ${gzfilename} = ${gzfilesize} >> build-report.txt
  \# copy zone.min.js to dist
  [[ $script == n* ]]
    cp $script dist/zone.min.js
  \# copy gzip and brotli versions of zone.js to dist
  [[ $brotlifilename == n* ]]
    mv $brotlifilename $rootdir
  [[ $gzfilename == n* ]]
    mv $gzfilename $rootdir
done
gregbown commented 7 years ago

Using the latest build on on brotli executable, even smaller!!!

file size report dist/bundle.js.brotli = 28353 dist/bundle.js.gz = 32416 node_modules/zone.js/dist/zone.min.js.brotli = 11699 node_modules/zone.js/dist/zone.min.js.gz = 12965