Skip to content

Commit 77006fb

Browse files
committed
chore: watch docs config files
1 parent 9725a10 commit 77006fb

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

docs/.vuepress/config.ts

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1+
import * as chokidar from 'chokidar'
12
import type { UserConfig } from '@vuepress/cli'
23
import type { DefaultThemeOptions } from '@vuepress/theme-default'
4+
import { chalk, logger } from '@vuepress/utils'
35
import { navbar, sidebar } from './configs'
46

57
const config: UserConfig<DefaultThemeOptions> = {
68
base: '/',
79

8-
evergreen: process.env.NODE_ENV !== 'production',
9-
1010
head: [['link', { rel: 'icon', href: `/logo.png` }]],
1111

1212
// site-level locales config
@@ -115,6 +115,20 @@ const config: UserConfig<DefaultThemeOptions> = {
115115
},
116116
],
117117
],
118+
119+
evergreen: process.env.NODE_ENV !== 'production',
120+
121+
onWatched: (_, restart) => {
122+
const watcher = chokidar.watch('configs/**/*.ts', {
123+
cwd: __dirname,
124+
ignoreInitial: true,
125+
})
126+
watcher.on('change', async (file) => {
127+
logger.info(`file ${chalk.magenta(file)} is modified`)
128+
await watcher.close()
129+
await restart()
130+
})
131+
},
118132
}
119133

120134
export = config

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
"@commitlint/config-conventional": "^11.0.0",
3636
"@types/jest": "^26.0.19",
3737
"anywhere": "^1.5.0",
38+
"chokidar": "^3.5.1",
3839
"cpx": "^1.5.0",
3940
"cross-env": "^7.0.3",
4041
"eslint": "^7.15.0",

0 commit comments

Comments
 (0)