[vite] globalThis.__VITE_MANIFEST__ is undefined
Open
Nobody has claimed this yet.
v3
- Dominant language
- TypeScript
- Stars
- 11.2k
- Forks
- 899
- Avg merge
- 2d 24m
- Merged PRs (30d)
- 40
Description
This value is not getting set in production on the server. The workaround is to use a plugin like:
const manifestPlugin = (): Plugin => {
let manifest = "{}";
const id = "#vite-manifest";
const resolvedId = `\0${id}`;
return {
name: "manifest",
applyToEnvironment(e) {
return e.name === "nitro"
},
config() { return { manifest: true } },
resolveId(possibleId) {
if (possibleId === id) {
return resolvedId
}
},
load(id) {
if (id === resolvedId) {
return `export default ${manifest}`
}
},
async buildStart(c) {
manifest = await fs.readFile("./.output/public/.vite/manifest.json", "utf-8");
},
}
}
and importing the manifest from "#vite-manifest"
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the production server behavior described in the issue and tracing where the Vite manifest is expected to be exposed. Compare that path with the supplied plugin workaround. Done means globalThis.VITE_MANIFEST is defined in production without requiring the workaround.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- build-system
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100