Skip to content

Commit 6bc711d

Browse files
committed
fix: avoid emitting index for ssr builds
1 parent 33a825d commit 6bc711d

File tree

1 file changed

+17
-13
lines changed

1 file changed

+17
-13
lines changed

adex/src/vite.js

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ export function adex({
130130
addFontsPlugin(fonts),
131131
adexDevServer({ islands }),
132132
adexBuildPrep({ islands }),
133-
adexClientBuilder({ islands }),
133+
adexClientBuilder({ ssr, islands }),
134134
adexIslandsBuilder(),
135135

136136
// SSR/Render Server Specific plugins
@@ -141,7 +141,7 @@ export function adex({
141141
/**
142142
* @returns {import("vite").Plugin}
143143
*/
144-
function adexClientBuilder({ islands = false } = {}) {
144+
function adexClientBuilder({ ssr = true, islands = false } = {}) {
145145
return {
146146
name: 'adex-client-builder',
147147
config(cfg) {
@@ -181,17 +181,21 @@ function adexClientBuilder({ islands = false } = {}) {
181181
return `<link rel="stylesheet" href="/${d}" />`
182182
})
183183

184-
this.emitFile({
185-
type: 'asset',
186-
fileName: 'index.html',
187-
source: `<html>
188-
<head>
189-
${links.join('\n')}
190-
</head>
191-
<div id="app"></div>
192-
<script src="/${clientEntryPath}" type="module"></script>
193-
</html>`,
194-
})
184+
if (!ssr) {
185+
this.emitFile({
186+
type: 'asset',
187+
fileName: 'index.html',
188+
source: `<html>
189+
<head>
190+
${links.join('\n')}
191+
</head>
192+
<body>
193+
<div id="app"></div>
194+
<script src="/${clientEntryPath}" type="module"></script>
195+
</body>
196+
</html>`,
197+
})
198+
}
195199
},
196200
}
197201
}

0 commit comments

Comments
 (0)