build: add runtime-global build for vue

This commit is contained in:
Evan You
2020-03-23 15:09:29 -04:00
parent f529dbde23
commit 4126a9dd51
3 changed files with 33 additions and 24 deletions

View File

@@ -148,18 +148,23 @@ function checkAllSizes(targets) {
function checkSize(target) {
const pkgDir = path.resolve(`packages/${target}`)
const esmProdBuild = `${pkgDir}/dist/${target}.global.prod.js`
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} / gzip:${gzippedSize} / brotli:${compressedSize}`
)
}
checkFileSize(`${pkgDir}/dist/${target}.global.prod.js`)
checkFileSize(`${pkgDir}/dist/${target}.runtime.global.prod.js`)
}
function checkFileSize(filePath) {
if (!fs.existsSync(filePath)) {
return
}
const file = fs.readFileSync(filePath)
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(path.basename(filePath))
)} min:${minSize} / gzip:${gzippedSize} / brotli:${compressedSize}`
)
}