file: resolve(`dist/${name}.esm-bundler.js`),
format: `es`
},
- // main "vue" package only
- 'esm-bundler-runtime': {
- file: resolve(`dist/${name}.runtime.esm-bundler.js`),
- format: `es`
- },
cjs: {
file: resolve(`dist/${name}.cjs.js`),
format: `cjs`
esm: {
file: resolve(`dist/${name}.esm.js`),
format: `es`
+ },
+ // main "vue" package only
+ 'esm-bundler-runtime': {
+ file: resolve(`dist/${name}.runtime.esm-bundler.js`),
+ format: `es`
+ },
+ 'global-runtime': {
+ file: resolve(`dist/${name}.runtime.global.js`),
+ format: 'iife'
}
}
if (format === 'cjs' && packageOptions.prod !== false) {
packageConfigs.push(createProductionConfig(format))
}
- if (format === 'global' || format === 'esm') {
+ if (/global/.test(format) || format === 'esm') {
packageConfigs.push(createMinifiedConfig(format))
}
})
const isProductionBuild =
process.env.__DEV__ === 'false' || /\.prod\.js$/.test(output.file)
- const isGlobalBuild = format === 'global'
+ const isGlobalBuild = /global/.test(format)
const isRawESMBuild = format === 'esm'
const isNodeBuild = format === 'cjs'
const isBundlerESMBuild = /esm-bundler/.test(format)
// during a single build.
hasTSChecked = true
- const entryFile =
- format === 'esm-bundler-runtime' ? `src/runtime.ts` : `src/index.ts`
+ const entryFile = /runtime$/.test(format) ? `src/runtime.ts` : `src/index.ts`
const external =
isGlobalBuild || isRawESMBuild
return createConfig(
format,
{
- file: resolve(`dist/${name}.${format}.prod.js`),
+ file: outputConfigs[format].file.replace(/\.js$/, '.prod.js'),
format: outputConfigs[format].format
},
[
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}`
+ )
}