From: Evan You Date: Fri, 4 Oct 2019 13:57:32 +0000 (-0400) Subject: build: report both gzip and brotli sizes X-Git-Tag: v3.0.0-alpha.0~618 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=4d2fa51347b1d8be7a4e7cea632b5694d54b2e79;p=thirdparty%2Fvuejs%2Fcore.git build: report both gzip and brotli sizes --- diff --git a/scripts/build.js b/scripts/build.js index b4d63ab21d..51eb6bc03a 100644 --- a/scripts/build.js +++ b/scripts/build.js @@ -19,6 +19,7 @@ const path = require('path') const zlib = require('zlib') const chalk = require('chalk') const execa = require('execa') +const { gzipSync } = require('zlib') const { compress } = require('brotli') const { targets: allTargets, fuzzyMatchTarget } = require('./utils') @@ -112,12 +113,14 @@ function checkSize(target) { if (fs.existsSync(esmProdBuild)) { const file = fs.readFileSync(esmProdBuild) const minSize = (file.length / 1024).toFixed(2) + 'kb' + const gzipped = gzipSync(file) + const gzippedSize = (gzipped.length / 1024).toFixed(2) + 'kb' const compressed = compress(file) const compressedSize = (compressed.length / 1024).toFixed(2) + 'kb' console.log( `${chalk.gray( chalk.bold(target) - )} min:${minSize} / brotli:${compressedSize}` + )} min:${minSize} / gzip:${gzippedSize} / brotli:${compressedSize}` ) } }