Created
March 18, 2021 14:49
-
-
Save fabiospampinato/c75cd5a1a4b1d567f9cfa2395a93cf08 to your computer and use it in GitHub Desktop.
bundle-bytes.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function bundle-bytes () { | |
#FIXME: code-only bundles, for some reaon the "--external" flags aren't respected | |
local full=`esbuild $@ --bundle --minify`; | |
local full_min=`echo $full | wc -c`; | |
local full_gzip=`echo $full | gzip | wc -c`; | |
local dependencies=`jq '.dependencies|keys[]' package.json`; | |
local dependencies_external=`echo $dependencies | sed -e 's/^/--external:/' | tr '\n' ' '`; | |
local code=`esbuild $@ --bundle --minify $dependencies_external`; | |
local code_min=`echo $code | wc -c`; | |
local code_gzip=`echo $code | gzip | wc -c`; | |
echo "Bundle (With dependencies)" | |
echo "$full_min (min)" | |
echo "$full_gzip (min+gzip)" | |
echo "Bundle (Without dependencies)" | |
echo "$code_min (min)" | |
echo "$code_gzip (min+gzip)" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment