Skip to content

Commit

Permalink
fix: load manifest with import.meta.glob (#30)
Browse files Browse the repository at this point in the history
  • Loading branch information
yusukebe authored Feb 4, 2024
1 parent 8a6acda commit a794022
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/server/components/script.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,15 @@ export const Script: FC<Options> = async (options) => {
if (options.prod ?? import.meta.env.PROD) {
let manifest: Manifest | undefined = options.manifest
if (!manifest) {
// @ts-expect-error not typed
const manifestFile = await import('/dist/.vite/manifest.json')
manifest = manifestFile['default']
const MANIFEST = import.meta.glob<{ default: Manifest }>('/dist/.vite/manifest.json', {
eager: true,
})
for (const [, manifestFile] of Object.entries(MANIFEST)) {
if (manifestFile['default']) {
manifest = manifestFile['default']
break
}
}
}
if (manifest) {
const scriptInManifest = manifest[src.replace(/^\//, '')]
Expand Down

0 comments on commit a794022

Please sign in to comment.