mirror of https://github.com/vuejs/vitepress
parent
a5e3d5d2f5
commit
0d462b4256
@ -0,0 +1,30 @@
|
||||
// copy and watch non-ts files in src/client
|
||||
const fs = require('fs-extra')
|
||||
const path = require('path')
|
||||
const globby = require('globby')
|
||||
const chokidar = require('chokidar')
|
||||
|
||||
const pattern = 'src/client/**/!(*.ts|tsconfig.json)'
|
||||
|
||||
function toDest(file) {
|
||||
return file.replace(/^src\//, 'dist/')
|
||||
}
|
||||
|
||||
function copy(file) {
|
||||
fs.copy(file, toDest(file))
|
||||
}
|
||||
|
||||
// copy on start
|
||||
;(async () => {
|
||||
for (const file of await globby(pattern)) {
|
||||
copy(file)
|
||||
}
|
||||
})()
|
||||
|
||||
chokidar
|
||||
.watch(pattern)
|
||||
.on('change', copy)
|
||||
.on('add', copy)
|
||||
.on('unlink', (file) => {
|
||||
fs.remove(toDest(file))
|
||||
})
|
Loading…
Reference in new issue