vue-web3/scripts/watch.ts
Georges KABBOUCHI 400a2d7581 Initial commit
2021-08-28 21:14:29 +03:00

26 lines
572 B
TypeScript

import { watch } from 'chokidar'
import { build } from 'unbuild'
import { resolve } from 'upath'
import consola from 'consola'
// Package root
const rootDir = resolve(__dirname, '..')
// Package src
const src = resolve(__dirname, '../src')
// Package build promise
const tryBuild = async () => {
try {
await build(rootDir, false)
} catch (e) {
consola.log(e)
} finally {
consola.info('Waiting for changes...')
}
}
// Watch src, rebuild on any change
watch(src).on('change', tryBuild)
watch(src).on('add', tryBuild)
watch(src).on('unlink', tryBuild)