fix: fix client build entry

pull/1189/head
Evan You 2 years ago
parent 1fcd1269b4
commit 04c4d0f01b

@ -45,7 +45,10 @@ export async function build(
const appChunk =
clientResult &&
(clientResult.output.find(
(chunk) => chunk.type === 'chunk' && chunk.isEntry
(chunk) =>
chunk.type === 'chunk' &&
chunk.isEntry &&
chunk.facadeModuleId?.endsWith('.js')
) as OutputChunk)
const cssChunk = (

@ -38,10 +38,7 @@ export async function bundle(
// resolve options to pass to vite
const { rollupOptions } = options
const resolveViteConfig = async (ssr: boolean): Promise<ViteUserConfig> => {
// use different entry based on ssr or not
input['app'] = path.resolve(APP_PATH, ssr ? 'ssr.js' : 'index.js')
return {
const resolveViteConfig = async (ssr: boolean): Promise<ViteUserConfig> => ({
root: config.srcDir,
base: config.site.base,
logLevel: 'warn',
@ -62,7 +59,11 @@ export async function bundle(
cssCodeSplit: false,
rollupOptions: {
...rollupOptions,
input,
input: {
...input,
// use different entry based on ssr or not
app: path.resolve(APP_PATH, ssr ? 'ssr.js' : 'index.js')
},
// important so that each page chunk and the index export things for each
// other
preserveEntrySignatures: 'allow-extension',
@ -100,8 +101,7 @@ export async function bundle(
// minify with esbuild in MPA mode (for CSS)
minify: ssr ? (config.mpa ? 'esbuild' : false) : !process.env.DEBUG
}
}
}
})
let clientResult: RollupOutput
let serverResult: RollupOutput

Loading…
Cancel
Save