From d0ea9009225c41aaf062292de3dd473924fcab04 Mon Sep 17 00:00:00 2001 From: Evan You Date: Sat, 11 Dec 2021 10:38:21 +0800 Subject: [PATCH] workflow: report brotli size of baseline build --- package.json | 2 +- packages/size-check/brotli.js | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 packages/size-check/brotli.js diff --git a/package.json b/package.json index 8385902f..ebea38cb 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,7 @@ "build": "node scripts/build.js", "size": "run-s size-global size-baseline", "size-global": "node scripts/build.js vue runtime-dom -f global -p", - "size-baseline": "node scripts/build.js runtime-dom runtime-core reactivity shared -f esm-bundler && cd packages/size-check && vite build", + "size-baseline": "node scripts/build.js runtime-dom runtime-core reactivity shared -f esm-bundler && cd packages/size-check && vite build && node brotli", "lint": "eslint --ext .ts packages/*/src/**.ts", "format": "prettier --write --parser typescript \"packages/**/*.ts?(x)\"", "test": "run-s \"test-unit -- {@}\" \"test-e2e -- {@}\" --", diff --git a/packages/size-check/brotli.js b/packages/size-check/brotli.js new file mode 100644 index 00000000..1e7ea0c7 --- /dev/null +++ b/packages/size-check/brotli.js @@ -0,0 +1,6 @@ +const { compress } = require('brotli') + +const file = require('fs').readFileSync('dist/index.js') +const compressed = compress(file) +const compressedSize = (compressed.length / 1024).toFixed(2) + 'kb' +console.log(`brotli: ${compressedSize}`)