Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix manifest handling in SSR mode #13

Merged
merged 1 commit into from
Jun 14, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This false return type is dedicated to @michaeldyrynda ❤️

{
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
}