perf: parallelize mpa chunks copy (#2389)

pull/2429/head
烽宁 2 years ago committed by GitHub
parent 0e962178ac
commit 6d7d195adc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -165,13 +165,15 @@ export async function bundle(
if (config.mpa) { if (config.mpa) {
// in MPA mode, we need to copy over the non-js asset files from the // in MPA mode, we need to copy over the non-js asset files from the
// server build since there is no client-side build. // server build since there is no client-side build.
for (const chunk of serverResult.output) { await Promise.all(
if (!chunk.fileName.endsWith('.js')) { serverResult.output.map(async (chunk) => {
const tempPath = path.resolve(config.tempDir, chunk.fileName) if (!chunk.fileName.endsWith('.js')) {
const outPath = path.resolve(config.outDir, chunk.fileName) const tempPath = path.resolve(config.tempDir, chunk.fileName)
await fs.copy(tempPath, outPath) const outPath = path.resolve(config.outDir, chunk.fileName)
} await fs.copy(tempPath, outPath)
} }
})
)
// also copy over public dir // also copy over public dir
const publicDir = path.resolve(config.srcDir, 'public') const publicDir = path.resolve(config.srcDir, 'public')
if (fs.existsSync(publicDir)) { if (fs.existsSync(publicDir)) {

Loading…
Cancel
Save