Is your problem is not with the line?
cp dist/production/index.js.gz dist/production/index.js
You are copying gzipped file, not the plain index.js text file.
Hope it helps.
If you are doing it on purpose why not maintain the gz extension. Extensions does lot of things when you handle with browser.
cp dist/production/index.js.gz dist/production/index.js.gz
If you use plain s3 to download and verify the hash, they should be the same file. I did verify it.