mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-27 16:12:12 +00:00
Merge pull request #617 from jroxendal/feature-generate-wait
[Feature] implemented staggered route generate. Fixes #590
This commit is contained in:
commit
296ea8ad4e
@ -89,11 +89,28 @@ export default function () {
|
|||||||
this.routes.push(route)
|
this.routes.push(route)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
var n = 0
|
||||||
|
function timer () {
|
||||||
|
let promise = new Promise(
|
||||||
|
(resolve, reject) => {
|
||||||
|
setTimeout( () => {
|
||||||
|
resolve()
|
||||||
|
}, self.options.generate.wait * n)
|
||||||
|
}
|
||||||
|
)
|
||||||
|
n++
|
||||||
|
return promise
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
let routes = this.routes
|
let routes = this.routes
|
||||||
return co(function * () {
|
return co(function * () {
|
||||||
while (routes.length) {
|
while (routes.length) {
|
||||||
yield routes.splice(0, 500).map((route) => {
|
yield routes.splice(0, 500).map((route) => {
|
||||||
return co(function * () {
|
return co(function * () {
|
||||||
|
if(self.options.generate.wait) {
|
||||||
|
yield timer()
|
||||||
|
}
|
||||||
var { html } = yield self.renderRoute(route, { _generate: true })
|
var { html } = yield self.renderRoute(route, { _generate: true })
|
||||||
html = minify(html, self.options.generate.minify)
|
html = minify(html, self.options.generate.minify)
|
||||||
var path = join(route, sep, 'index.html') // /about -> /about/index.html
|
var path = join(route, sep, 'index.html') // /about -> /about/index.html
|
||||||
|
3
test/fixtures/basic/nuxt.config.js
vendored
3
test/fixtures/basic/nuxt.config.js
vendored
@ -4,6 +4,7 @@ module.exports = {
|
|||||||
'/users/1',
|
'/users/1',
|
||||||
'/users/2',
|
'/users/2',
|
||||||
'/users/3'
|
'/users/3'
|
||||||
]
|
],
|
||||||
|
wait : 1000
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user