Skip to content

Instantly share code, notes, and snippets.

@fabiospampinato
Created March 18, 2021 14:49
Show Gist options
  • Save fabiospampinato/c75cd5a1a4b1d567f9cfa2395a93cf08 to your computer and use it in GitHub Desktop.
Save fabiospampinato/c75cd5a1a4b1d567f9cfa2395a93cf08 to your computer and use it in GitHub Desktop.
bundle-bytes.sh
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