perf: use parallel builds

pull/137/head
Evan You 5 years ago
parent aca74b281f
commit d3accf3806

@ -15,6 +15,7 @@ export type BuildOptions = Pick<
>
export async function build(buildOptions: BuildOptions = {}) {
const start = Date.now()
process.env.NODE_ENV = 'production'
const siteConfig = await resolveConfig(buildOptions.root)
@ -66,5 +67,5 @@ export async function build(buildOptions: BuildOptions = {}) {
} finally {
await fs.remove(siteConfig.tempDir)
}
console.log('✨ done.')
console.log(`✨ done in ${((Date.now() - start) / 1000).toFixed(2)}s.`)
}

@ -153,26 +153,15 @@ export async function bundle(
let clientResult, serverResult
const spinner = ora()
spinner.start('building client bundle...')
spinner.start('building client + server bundles...')
try {
clientResult = await build(viteOptions)
} catch (e) {
spinner.stopAndPersist({
symbol: failMark
})
throw e
}
spinner.stopAndPersist({
symbol: okMark
})
spinner.start('building server bundle...')
isClientBuild = false
try {
serverResult = await ssrBuild({
;[clientResult, serverResult] = await Promise.all([
build(viteOptions),
ssrBuild({
...viteOptions,
outDir: config.tempDir
})
])
} catch (e) {
spinner.stopAndPersist({
symbol: failMark

Loading…
Cancel
Save