Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions packages/@vuepress/core/lib/node/build/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ module.exports = class Build extends EventEmitter {
constructor (context) {
super()
this.context = context
this.maxConcurrency = this.context.options.maxConcurrency
this.outDir = this.context.outDir
}

Expand Down Expand Up @@ -90,10 +91,16 @@ module.exports = class Build extends EventEmitter {

// render pages
logger.wait('Rendering static HTML...')

const pagePaths = await Promise.all(
this.context.pages.map(page => this.renderPage(page))
)
if (this.maxConcurrency) logger.info(`max concurrency set: ${this.maxConcurrency}`)

const pagePaths = []
while (this.context.pages.length) {
const segmentPaths = await Promise.all(
this.context.pages.splice(0, this.maxConcurrency || 100000)
.map(page => this.renderPage(page))
)
pagePaths.push(...segmentPaths)
}

readline.clearLine(process.stdout, 0)
readline.cursorTo(process.stdout, 0)
Expand Down
1 change: 1 addition & 0 deletions packages/vuepress/lib/registerCoreCommands.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ module.exports = function (cli, options) {
.option('--no-cache', 'clean the cache before build')
.option('--debug', 'build in development mode for debugging')
.option('--silent', 'build static site in silent mode')
.option('--max-concurrency', 'set the max docs concurrently processed when build static site')
.action((sourceDir = '.', commandOptions) => {
const { debug, silent } = commandOptions

Expand Down