Closed NicholasJupiter closed 10 months ago
I am also seeing this on Vite 5. It is because Vite 5 renamed the manifest file to .vite/manifest.json
, but @crxjs/vite-plugin
tries to look for it at manifest.json
.
Here is a workaround that appears to work (in your vite.config.ts
):
const viteManifestHackIssue846: Plugin & { renderCrxManifest: (manifest: any, bundle: any) => void } = {
// Workaround from https://github.com/crxjs/chrome-extension-tools/issues/846#issuecomment-1861880919.
name: 'manifestHackIssue846',
renderCrxManifest(_manifest, bundle) {
bundle['manifest.json'] = bundle['.vite/manifest.json']
bundle['manifest.json'].fileName = 'manifest.json'
delete bundle['.vite/manifest.json']
},
}
export default defineConfig({
plugins: [/* ... */, viteManifestHackIssue846, crx(/* ... */)],
// ....
})
This was actually addressed in this PR there's no need to hack vite anymore
I am not sure why this is marked as completed, I updated to the latest and it's still giving me the same manifest missing issue, the workaround posted by @sqs still works.
I am not sure why this is marked as completed, I updated to the latest and it's still giving me the same manifest missing issue, the workaround posted by @sqs still works.
yes,I agree with you. But this patch will cause new problems: old files will not be cleaned automatically, I don't know if it is my problem
this is still the case I believe today
A workaround for temperory:
@HawtinZeng this worked for me.....
@HawtinZeng Worked like a charm. Much appreciated.
Maybe we need to endure this bug until Vite api get stable for a while.
Revise the dist again would be painful each time, please resolve this
The workaround given above works for v1.x.x of this project if you also install newer versions of Vite v4+.
If like me you have Vite v5 (due to other plugin peer dependencies) and the latest stable version of this project still gives an error, you can install v2-beta of this project. This is the release that fixes this issue (but install a newer version ofc): https://github.com/crxjs/chrome-extension-tools/releases/tag/%40crxjs%2Fvite-plugin%402.0.0-beta.22
Build tool
Vite
Where do you see the problem?
Describe the bug
vite v5.0.4 building for production... ✓ 1426 modules transformed. [crx:content-script-resources] Error: vite manifest is missing at Object.renderCrxManifest (file:///Users/xiongyi/Desktop/wongta/extension-x-tower/node_modules/@crxjs/vite-plugin/dist/index.mjs:3240:21) at Object.generateBundle (file:///Users/xiongyi/Desktop/wongta/extension-x-tower/node_modules/@crxjs/vite-plugin/dist/index.mjs:2922:60) at async Bundle.generate (file:///Users/xiongyi/Desktop/wongta/extension-x-tower/node_modules/vite/node_modules/rollup/dist/es/shared/node-entry.js:16973:9) at async file:///Users/xiongyi/Desktop/wongta/extension-x-tower/node_modules/vite/node_modules/rollup/dist/es/shared/node-entry.js:19519:27 at async catchUnfinishedHookActions (file:///Users/xiongyi/Desktop/wongta/extension-x-tower/node_modules/vite/node_modules/rollup/dist/es/shared/node-entry.js:18950:16) at async build (file:///Users/xiongyi/Desktop/wongta/extension-x-tower/node_modules/vite/dist/node/chunks/dep-4RECYSE1.js:66261:22) at async CAC. (file:///Users/xiongyi/Desktop/wongta/extension-x-tower/node_modules/vite/dist/node/cli.js:845:9)
[crx:manifest-post] Error in crx:content-script-resources.renderCrxManifest
✓ built in 3.63s
error during build:
Error: Error in crx:content-script-resources.renderCrxManifest
at Object.generateBundle (file:///Users/xiongyi/Desktop/wongta/extension-x-tower/node_modules/@crxjs/vite-plugin/dist/index.mjs:2933:19)
at async Bundle.generate (file:///Users/xiongyi/Desktop/wongta/extension-x-tower/node_modules/vite/node_modules/rollup/dist/es/shared/node-entry.js:16973:9)
at async file:///Users/xiongyi/Desktop/wongta/extension-x-tower/node_modules/vite/node_modules/rollup/dist/es/shared/node-entry.js:19519:27
at async catchUnfinishedHookActions (file:///Users/xiongyi/Desktop/wongta/extension-x-tower/node_modules/vite/node_modules/rollup/dist/es/shared/node-entry.js:18950:16)
at async build (file:///Users/xiongyi/Desktop/wongta/extension-x-tower/node_modules/vite/dist/node/chunks/dep-4RECYSE1.js:66261:22)
at async CAC. (file:///Users/xiongyi/Desktop/wongta/extension-x-tower/node_modules/vite/dist/node/cli.js:845:9)
error Command failed with exit code 1.
Reproduction
vite build
Logs
No response
System Info
Severity
annoyance