2023-05-04 10:39:52 +08:00
|
|
|
import minimist from 'minimist'
|
|
|
|
import consola from 'consola'
|
2023-04-28 15:35:54 +08:00
|
|
|
|
2023-05-04 10:39:52 +08:00
|
|
|
import { distPath, exec } from './utils'
|
|
|
|
import { checkSize } from './checkSize'
|
|
|
|
import { safeExit } from './utils'
|
2023-03-23 20:09:00 +08:00
|
|
|
|
2023-05-04 10:39:52 +08:00
|
|
|
const args = minimist(process.argv.slice(2))
|
|
|
|
const watch = Boolean(args.watch || args.w)
|
|
|
|
const all = Boolean(args.all || args.a)
|
|
|
|
const sourceMap = all || Boolean(args.sourceMap || args.s)
|
|
|
|
const dts = all || Boolean(args.dts || args.d)
|
2023-03-23 20:09:00 +08:00
|
|
|
|
2023-05-04 10:39:52 +08:00
|
|
|
main()
|
2023-03-23 20:09:00 +08:00
|
|
|
|
2023-03-28 21:53:26 +08:00
|
|
|
function main() {
|
2023-05-04 10:39:52 +08:00
|
|
|
exec('rimraf dist')
|
|
|
|
|
|
|
|
consola.info('Rollup')
|
|
|
|
|
|
|
|
safeExit(() => {
|
|
|
|
exec(
|
|
|
|
`rollup -c rollup.config.ts --configPlugin typescript ${
|
|
|
|
watch ? '-w' : ''
|
|
|
|
} --environment SOURCE_MAP:${sourceMap},DTS:${dts}`,
|
|
|
|
)
|
|
|
|
})
|
|
|
|
|
|
|
|
if (!watch) {
|
|
|
|
checkSize(`${distPath}/**.js`)
|
|
|
|
}
|
|
|
|
|
|
|
|
console.info('\n')
|
2023-03-23 20:09:00 +08:00
|
|
|
}
|