mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-27 08:02:01 +00:00
parent
8d21b60a24
commit
1842a3b5cb
@ -35,9 +35,11 @@ export default class Builder {
|
||||
this.compilersWatching = []
|
||||
this.webpackDevMiddleware = null
|
||||
this.webpackHotMiddleware = null
|
||||
this.filesWatcher = null
|
||||
this.customFilesWatcher = null
|
||||
this.nuxtRestartWatcher = null
|
||||
this.watchers = {
|
||||
files: null,
|
||||
custom: null,
|
||||
restart: null
|
||||
}
|
||||
this.perfLoader = null
|
||||
|
||||
// Helper to resolve build paths
|
||||
@ -610,7 +612,7 @@ export default class Builder {
|
||||
const refreshFiles = _.debounce(() => this.generateRoutesAndFiles(), 200)
|
||||
|
||||
// Watch for src Files
|
||||
this.filesWatcher = chokidar
|
||||
this.watchers.files = chokidar
|
||||
.watch(patterns, options)
|
||||
.on('add', refreshFiles)
|
||||
.on('unlink', refreshFiles)
|
||||
@ -621,7 +623,7 @@ export default class Builder {
|
||||
..._.values(_.omit(this.options.build.styleResources, ['options']))
|
||||
)
|
||||
customPatterns = _.map(_.uniq(customPatterns), upath.normalizeSafe)
|
||||
this.customFilesWatcher = chokidar
|
||||
this.watchers.custom = chokidar
|
||||
.watch(customPatterns, options)
|
||||
.on('change', refreshFiles)
|
||||
|
||||
@ -631,10 +633,10 @@ export default class Builder {
|
||||
})
|
||||
|
||||
const nuxtRestartWatch = _.concat(
|
||||
this.options.watch,
|
||||
this.options.watch.map(r),
|
||||
path.join(this.options.rootDir, 'nuxt.config.js')
|
||||
)
|
||||
this.nuxtRestartWatcher = chokidar
|
||||
this.watchers.restart = chokidar
|
||||
.watch(nuxtRestartWatch, options)
|
||||
.on('change', (event, _path) => {
|
||||
const parsedPath = path.parse(_path)
|
||||
@ -643,16 +645,10 @@ export default class Builder {
|
||||
}
|
||||
|
||||
async unwatch() {
|
||||
if (this.filesWatcher) {
|
||||
this.filesWatcher.close()
|
||||
}
|
||||
|
||||
if (this.customFilesWatcher) {
|
||||
this.customFilesWatcher.close()
|
||||
}
|
||||
|
||||
if (this.nuxtRestartWatcher) {
|
||||
this.nuxtRestartWatcher.close()
|
||||
for (const watcher in this.watchers) {
|
||||
if (this.watchers[watcher]) {
|
||||
this.watchers[watcher].close()
|
||||
}
|
||||
}
|
||||
|
||||
this.compilersWatching.forEach(watching => watching.close())
|
||||
|
2
test/fixtures/cli/nuxt.config.js
vendored
2
test/fixtures/cli/nuxt.config.js
vendored
@ -1,3 +1,3 @@
|
||||
export default {
|
||||
watch: ['./custom.file']
|
||||
watch: ['~/custom.file']
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user