mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-27 16:12:12 +00:00
[modules] Watch for template changes
`build.watch` option was added
This commit is contained in:
parent
2c37811032
commit
12727d1165
@ -58,7 +58,8 @@ const defaults = {
|
||||
plugins: [],
|
||||
babel: {},
|
||||
postcss: [],
|
||||
templates: []
|
||||
templates: [],
|
||||
watch: []
|
||||
}
|
||||
const defaultsLoaders = [
|
||||
{
|
||||
@ -512,7 +513,7 @@ function watchPages () {
|
||||
r(this.srcDir, 'pages/**/*.vue'),
|
||||
r(this.srcDir, 'layouts/*.vue'),
|
||||
r(this.srcDir, 'layouts/**/*.vue')
|
||||
]
|
||||
].concat(this.options.build.watch)
|
||||
const options = Object.assign({}, this.options.watchers.chokidar, {
|
||||
ignoreInitial: true
|
||||
})
|
||||
@ -520,7 +521,7 @@ function watchPages () {
|
||||
const refreshFiles = _.debounce(() => {
|
||||
co(generateRoutesAndFiles.bind(this))
|
||||
}, 200)
|
||||
this.pagesFilesWatcher = chokidar.watch(patterns, options)
|
||||
this.pagesFilesWatcher = chokidar.watch(_.uniq(patterns), options)
|
||||
.on('add', refreshFiles)
|
||||
.on('unlink', refreshFiles)
|
||||
}
|
||||
|
@ -34,7 +34,6 @@ class Module {
|
||||
// Generate unique and human readable dst filename
|
||||
const dst = template.fileName ||
|
||||
(path.basename(srcPath.dir) + '.' + srcPath.name + '.' + hash(src) + '.' + srcPath.ext)
|
||||
|
||||
// Add to templates list
|
||||
const templateObj = {
|
||||
src,
|
||||
@ -42,9 +41,15 @@ class Module {
|
||||
options: template.options
|
||||
}
|
||||
this.options.build.templates.push(templateObj)
|
||||
// Watch template for changes
|
||||
this.addWatch(src)
|
||||
return templateObj
|
||||
}
|
||||
|
||||
addWatch (pattern) {
|
||||
this.options.build.watch.push(pattern)
|
||||
}
|
||||
|
||||
addPlugin (template) {
|
||||
const {dst} = this.addTemplate(template)
|
||||
// Add to nuxt plugins
|
||||
|
Loading…
Reference in New Issue
Block a user