Skip to content

Commit

Permalink
Fix sandboxes with html file on a non-default path
Browse files Browse the repository at this point in the history
Fixes #4737
  • Loading branch information
CompuIves committed Aug 19, 2020
1 parent 17ade25 commit ae439e5
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions packages/app/src/sandbox/compile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -577,9 +577,8 @@ async function compile({
await manager.preset.preEvaluate(manager, updatedModules);

if (!manager.webpackHMR) {
const htmlModulePath = templateDefinition
.getHTMLEntries(configurations)
.find(p => Boolean(modules[p]));
const htmlEntries = templateDefinition.getHTMLEntries(configurations);
const htmlModulePath = htmlEntries.find(p => Boolean(modules[p]));
const htmlModule = modules[htmlModulePath];

const { head, body } = getHTMLParts(
Expand All @@ -597,7 +596,11 @@ async function compile({
manager.clearCompiledCache();
}

if (!htmlModule || !firstLoad || process.env.LOCAL_SERVER) {
// Whether the server has provided the HTML file. If that isn't the case
// we have to fall back to setting `document.body;innerHTML`, which isn't
// preferred.
const serverProvidedHTML = modules[htmlEntries[0]];
if (!serverProvidedHTML || !firstLoad || process.env.LOCAL_SERVER) {
// The HTML is loaded from the server as a static file, no need to set the innerHTML of the body
// on the first run.
document.body.innerHTML = body;
Expand Down

0 comments on commit ae439e5

Please sign in to comment.