Skip to content

Commit

Permalink
fix: html not found in dev
Browse files Browse the repository at this point in the history
  • Loading branch information
sanyuan0704 committed Sep 30, 2022
1 parent 44de3c3 commit 39d6ef9
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/node/plugin-island/indexHtml.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
import { SiteConfig } from 'shared/types/index';
import { Plugin } from 'vite';
import fs from 'fs-extra';
import { join } from 'path';

export function pluginIndexHtml(config: SiteConfig): Plugin {
return {
Expand Down Expand Up @@ -51,8 +52,12 @@ export function pluginIndexHtml(config: SiteConfig): Plugin {
if (res.writableEnded) {
return next();
}
const indexHtmlInRoot = join(config.root, '.island', 'index.html');
const templatePath = (await fs.pathExists(indexHtmlInRoot))
? indexHtmlInRoot
: DEFAULT_HTML_PATH;
if (req.url?.replace(/\?.*/, '')) {
let html = fs.readFileSync(DEFAULT_HTML_PATH, 'utf8');
let html = fs.readFileSync(templatePath, 'utf8');

try {
html = await server.transformIndexHtml(
Expand Down

0 comments on commit 39d6ef9

Please sign in to comment.