mirror of https://github.com/vuejs/vitepress
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
32 lines
1.0 KiB
32 lines
1.0 KiB
const fs = require('fs-extra')
|
|
const chokidar = require('chokidar')
|
|
|
|
function toClientAndNode(method, file) {
|
|
if (method === 'copy') {
|
|
fs.copy(file, file.replace(/^src\//, 'src/node/'))
|
|
fs.copy(file, file.replace(/^src\//, 'src/client/'))
|
|
} else if (method === 'remove') {
|
|
fs.remove(file.replace(/^src\//, 'src/node/'))
|
|
fs.remove(file.replace(/^src\//, 'src/client/'))
|
|
}
|
|
}
|
|
|
|
function toDist(file) {
|
|
return file.replace(/^src\//, 'dist/')
|
|
}
|
|
|
|
// copy shared files to the client and node directory whenever they change.
|
|
chokidar
|
|
.watch('src/shared/**/*.ts')
|
|
.on('change', (file) => toClientAndNode('copy', file))
|
|
.on('add', (file) => toClientAndNode('copy', file))
|
|
.on('unlink', (file) => toClientAndNode('remove', file))
|
|
|
|
// copy non ts files, such as an html or css, to the dist directory whenever
|
|
// they change.
|
|
chokidar
|
|
.watch('src/client/**/!(*.ts|tsconfig.json)')
|
|
.on('change', (file) => fs.copy(file, toDist(file)))
|
|
.on('add', (file) => fs.copy(file, toDist(file)))
|
|
.on('unlink', (file) => fs.remove(toDist(file)))
|