build: use brotli for checking compressed file sizes
This commit is contained in:
parent
e5bc17967d
commit
4021307f4c
@ -27,6 +27,7 @@
|
|||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@microsoft/api-extractor": "^7.3.9",
|
"@microsoft/api-extractor": "^7.3.9",
|
||||||
"@types/jest": "^24.0.18",
|
"@types/jest": "^24.0.18",
|
||||||
|
"brotli": "^1.3.2",
|
||||||
"chalk": "^2.4.2",
|
"chalk": "^2.4.2",
|
||||||
"execa": "^2.0.4",
|
"execa": "^2.0.4",
|
||||||
"fs-extra": "^8.1.0",
|
"fs-extra": "^8.1.0",
|
||||||
|
@ -19,6 +19,7 @@ const path = require('path')
|
|||||||
const zlib = require('zlib')
|
const zlib = require('zlib')
|
||||||
const chalk = require('chalk')
|
const chalk = require('chalk')
|
||||||
const execa = require('execa')
|
const execa = require('execa')
|
||||||
|
const { compress } = require('brotli')
|
||||||
const { targets, fuzzyMatchTarget } = require('./utils')
|
const { targets, fuzzyMatchTarget } = require('./utils')
|
||||||
|
|
||||||
const args = require('minimist')(process.argv.slice(2))
|
const args = require('minimist')(process.argv.slice(2))
|
||||||
@ -109,10 +110,12 @@ function checkSize(target) {
|
|||||||
if (fs.existsSync(esmProdBuild)) {
|
if (fs.existsSync(esmProdBuild)) {
|
||||||
const file = fs.readFileSync(esmProdBuild)
|
const file = fs.readFileSync(esmProdBuild)
|
||||||
const minSize = (file.length / 1024).toFixed(2) + 'kb'
|
const minSize = (file.length / 1024).toFixed(2) + 'kb'
|
||||||
const gzipped = zlib.gzipSync(file)
|
const compressed = compress(file)
|
||||||
const gzipSize = (gzipped.length / 1024).toFixed(2) + 'kb'
|
const compressedSize = (compressed.length / 1024).toFixed(2) + 'kb'
|
||||||
console.log(
|
console.log(
|
||||||
`${chalk.gray(chalk.bold(target))} min:${minSize} / gzip:${gzipSize}`
|
`${chalk.gray(
|
||||||
|
chalk.bold(target)
|
||||||
|
)} min:${minSize} / brotli:${compressedSize}`
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
12
yarn.lock
12
yarn.lock
@ -1618,6 +1618,11 @@ balanced-match@^1.0.0:
|
|||||||
resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.0.tgz#89b4d199ab2bee49de164ea02b89ce462d71b767"
|
resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.0.tgz#89b4d199ab2bee49de164ea02b89ce462d71b767"
|
||||||
integrity sha1-ibTRmasr7kneFk6gK4nORi1xt2c=
|
integrity sha1-ibTRmasr7kneFk6gK4nORi1xt2c=
|
||||||
|
|
||||||
|
base64-js@^1.1.2:
|
||||||
|
version "1.3.1"
|
||||||
|
resolved "https://registry.yarnpkg.com/base64-js/-/base64-js-1.3.1.tgz#58ece8cb75dd07e71ed08c736abc5fac4dbf8df1"
|
||||||
|
integrity sha512-mLQ4i2QO1ytvGWFWmcngKO//JXAQueZvwEKtjgQFM4jIK0kU+ytMfplL8j+n5mspOfjHwoAg+9yhb7BwAHm36g==
|
||||||
|
|
||||||
base@^0.11.1:
|
base@^0.11.1:
|
||||||
version "0.11.2"
|
version "0.11.2"
|
||||||
resolved "https://registry.yarnpkg.com/base/-/base-0.11.2.tgz#7bde5ced145b6d551a90db87f83c558b4eb48a8f"
|
resolved "https://registry.yarnpkg.com/base/-/base-0.11.2.tgz#7bde5ced145b6d551a90db87f83c558b4eb48a8f"
|
||||||
@ -1684,6 +1689,13 @@ braces@^3.0.1:
|
|||||||
dependencies:
|
dependencies:
|
||||||
fill-range "^7.0.1"
|
fill-range "^7.0.1"
|
||||||
|
|
||||||
|
brotli@^1.3.2:
|
||||||
|
version "1.3.2"
|
||||||
|
resolved "https://registry.yarnpkg.com/brotli/-/brotli-1.3.2.tgz#525a9cad4fcba96475d7d388f6aecb13eed52f46"
|
||||||
|
integrity sha1-UlqcrU/LqWR119OI9q7LE+7VL0Y=
|
||||||
|
dependencies:
|
||||||
|
base64-js "^1.1.2"
|
||||||
|
|
||||||
browser-process-hrtime@^0.1.2:
|
browser-process-hrtime@^0.1.2:
|
||||||
version "0.1.2"
|
version "0.1.2"
|
||||||
resolved "https://registry.yarnpkg.com/browser-process-hrtime/-/browser-process-hrtime-0.1.2.tgz#425d68a58d3447f02a04aa894187fce8af8b7b8e"
|
resolved "https://registry.yarnpkg.com/browser-process-hrtime/-/browser-process-hrtime-0.1.2.tgz#425d68a58d3447f02a04aa894187fce8af8b7b8e"
|
||||||
|
Loading…
Reference in New Issue
Block a user