mirror of https://github.com/vuejs/vitepress
commit
f4f019eaec
@ -1,4 +1,6 @@
|
|||||||
/dist
|
/dist
|
||||||
/node_modules
|
/node_modules
|
||||||
|
/src/client/shared
|
||||||
|
/src/node/shared
|
||||||
*.log
|
*.log
|
||||||
.DS_Store
|
.DS_Store
|
||||||
|
@ -0,0 +1,7 @@
|
|||||||
|
const fs = require('fs-extra')
|
||||||
|
const glob = require('globby')
|
||||||
|
|
||||||
|
glob.sync('src/shared/**/*.ts').forEach((file) => {
|
||||||
|
fs.copy(file, file.replace(/^src\//, 'src/node/'))
|
||||||
|
fs.copy(file, file.replace(/^src\//, 'src/client/'))
|
||||||
|
})
|
@ -1,13 +1,31 @@
|
|||||||
// copy and watch non-ts files in src/client
|
|
||||||
const fs = require('fs-extra')
|
const fs = require('fs-extra')
|
||||||
const chokidar = require('chokidar')
|
const chokidar = require('chokidar')
|
||||||
|
|
||||||
function toDest(file) {
|
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/')
|
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
|
chokidar
|
||||||
.watch('src/client/**/!(*.ts|tsconfig.json)')
|
.watch('src/client/**/!(*.ts|tsconfig.json)')
|
||||||
.on('change', (file) => fs.copy(file, toDest(file)))
|
.on('change', (file) => fs.copy(file, toDist(file)))
|
||||||
.on('add', (file) => fs.copy(file, toDest(file)))
|
.on('add', (file) => fs.copy(file, toDist(file)))
|
||||||
.on('unlink', (file) => fs.remove(toDest(file)))
|
.on('unlink', (file) => fs.remove(toDist(file)))
|
||||||
|
@ -1,10 +1,17 @@
|
|||||||
{
|
{
|
||||||
"extends": "../../tsconfig.base.json",
|
"extends": "../../tsconfig.base.json",
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"outDir": "../../dist",
|
"baseUrl": ".",
|
||||||
|
"outDir": "../../dist/node",
|
||||||
"module": "commonjs",
|
"module": "commonjs",
|
||||||
"lib": ["ESNext", "DOM"],
|
"lib": ["ESNext", "DOM"],
|
||||||
"sourceMap": true
|
"sourceMap": true,
|
||||||
|
"paths": {
|
||||||
|
"/@types/*": ["../../types/*"]
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"include": [".", "../shared", "../../types/shared.d.ts"]
|
"include": [
|
||||||
|
".",
|
||||||
|
"../../types/shared.d.ts"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in new issue