mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-11 08:33:53 +00:00
fix(builder): watch for pages/
creation when default page displayed (#5753)
This commit is contained in:
parent
21aaef3b48
commit
e75d65b268
@ -604,7 +604,7 @@ export default class Builder {
|
||||
patterns.push(r(src, this.options.dir.store))
|
||||
}
|
||||
|
||||
if (this._nuxtPages) {
|
||||
if (this._nuxtPages && !this._defaultPage) {
|
||||
patterns.push(
|
||||
r(src, this.options.dir.pages),
|
||||
...rGlob(this.options.dir.pages)
|
||||
@ -657,6 +657,10 @@ export default class Builder {
|
||||
if (this.ignore.ignoreFile) {
|
||||
nuxtRestartWatch.push(this.ignore.ignoreFile)
|
||||
}
|
||||
// If default page displayed, watch for first page creation
|
||||
if (this._nuxtPages && this._defaultPage) {
|
||||
nuxtRestartWatch.push(path.join(this.options.srcDir, this.options.dir.pages))
|
||||
}
|
||||
// If store not activated, watch for a file in the directory
|
||||
if (!this.options.store) {
|
||||
nuxtRestartWatch.push(path.join(this.options.srcDir, this.options.dir.store))
|
||||
|
@ -87,6 +87,29 @@ describe('builder: builder watch', () => {
|
||||
expect(r).nthCalledWith(5, '/var/nuxt/src', '/var/nuxt/src/store')
|
||||
})
|
||||
|
||||
test('should NOT watch pages files on client if _defaultPage=true', () => {
|
||||
const nuxt = createNuxt()
|
||||
nuxt.options.srcDir = '/var/nuxt/src'
|
||||
nuxt.options.dir = {
|
||||
layouts: '/var/nuxt/src/layouts',
|
||||
pages: '/var/nuxt/src/pages',
|
||||
store: '/var/nuxt/src/store',
|
||||
middleware: '/var/nuxt/src/middleware'
|
||||
}
|
||||
nuxt.options.build.watch = []
|
||||
nuxt.options.watchers = {
|
||||
chokidar: { test: true }
|
||||
}
|
||||
|
||||
const builder = new Builder(nuxt, {})
|
||||
builder._nuxtPages = true
|
||||
builder._defaultPage = true
|
||||
r.mockImplementation((dir, src) => src)
|
||||
|
||||
builder.watchClient()
|
||||
|
||||
expect(r).toBeCalledTimes(4)
|
||||
})
|
||||
test('should watch pages files', () => {
|
||||
const nuxt = createNuxt()
|
||||
nuxt.options.srcDir = '/var/nuxt/src'
|
||||
|
Loading…
Reference in New Issue
Block a user