Add generate.concurrency option

This commit is contained in:
Sébastien Chopin 2017-07-09 12:00:08 +02:00
parent 9e2c4b9761
commit 270c490a9d
2 changed files with 2 additions and 1 deletions

View File

@ -68,7 +68,7 @@ export default class Generator extends Tapable {
// Start generate process // Start generate process
while (routes.length) { while (routes.length) {
let n = 0 let n = 0
await Promise.all(routes.splice(0, 500).map(async ({ route, payload }) => { await Promise.all(routes.splice(0, this.options.generate.concurrency).map(async ({ route, payload }) => {
await waitFor(n++ * this.options.generate.interval) await waitFor(n++ * this.options.generate.interval)
await this.generateRoute({route, payload, errors}) await this.generateRoute({route, payload, errors})
})) }))

View File

@ -74,6 +74,7 @@ export const defaultOptions = {
generate: { generate: {
dir: 'dist', dir: 'dist',
routes: [], routes: [],
concurrency: 500,
interval: 0, interval: 0,
minify: { minify: {
collapseBooleanAttributes: true, collapseBooleanAttributes: true,