Skip to content

Commit

Permalink
fix(build): always render the index.html
Browse files Browse the repository at this point in the history
If `build` or `ssrBuild` are called programmatically with `write: false`, the index.html output still needs to exist in the returned array of `BuildResult` objects.
  • Loading branch information
aleclarson committed Oct 28, 2020
1 parent e5fdc7e commit 5e7c309
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/node/build/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -568,7 +568,7 @@ export async function build(
assetFileNames: `[name].[hash].[ext]`,
...config.rollupOutputOptions
})
build.html = emitIndex ? await renderIndex(output) : ''
build.html = await renderIndex(output)
build.assets = output
await postBuildHooks.reduce(
(queue, hook) => queue.then(() => hook(build as any)),
Expand Down Expand Up @@ -628,7 +628,7 @@ export async function build(
}
}

if (build.html) {
if (emitIndex) {
const outputHtmlPath = path.join(outDir, build.id + '.html')
await fs.writeFile(outputHtmlPath, build.html)
await printFilesInfo(outputHtmlPath, build.html, WriteType.HTML)
Expand Down

0 comments on commit 5e7c309

Please sign in to comment.