Skip to content

Commit

Permalink
Merge pull request #13 from laravel/fix-ssr-build
Browse files Browse the repository at this point in the history
Fix manifest handling in SSR mode
  • Loading branch information
timacdonald committed Jun 14, 2022
2 parents d8860eb + 868ab9a commit 902a2ef
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,13 @@ export default function laravel(config?: string|string[]|Partial<PluginConfig>):
return null
},
writeBundle() {
const manifestPath = path.resolve(resolvedConfig.root, resolvedConfig.build.outDir, 'manifest.json')
const manifestConfig = resolveManifestConfig(resolvedConfig)

if (manifestConfig === false) {
return;
}

const manifestPath = path.resolve(resolvedConfig.root, resolvedConfig.build.outDir, manifestConfig)
const manifest = JSON.parse(fs.readFileSync(manifestPath).toString())
const newManifest = {
...manifest,
Expand Down Expand Up @@ -259,3 +265,20 @@ function resolveOutDir(config: PluginConfig, ssr: boolean): string|undefined {

return path.join(config.publicDirectory, config.buildDirectory)
}

function resolveManifestConfig(config: ResolvedConfig): string|false
{
const manifestConfig = config.build.ssr
? config.build.ssrManifest
: config.build.manifest;

if (manifestConfig === false) {
return false
}

if (manifestConfig === true) {
return config.build.ssr ? 'ssr-manifest.json' : 'manifest.json'
}

return manifestConfig
}

0 comments on commit 902a2ef

Please sign in to comment.