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

[crx:content-script-resources] Error: vite manifest is missing #846

Closed
1 of 2 tasks
NicholasJupiter opened this issue Dec 14, 2023 · 11 comments
Closed
1 of 2 tasks

Comments

@NicholasJupiter
Copy link

Build tool

Vite

Where do you see the problem?

  • In the browser
  • In the terminal

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

"@crxjs/vite-plugin": "^1.0.14",
"vite": "^5.0.0"

Severity

annoyance

@sqs
Copy link

sqs commented Dec 19, 2023

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(/* ... */)],
    // ....
})

@kaminskypavel
Copy link

This was actually addressed in this PR
there's no need to hack vite anymore

@AmySteam AmySteam closed this as completed Feb 2, 2024
@hyusetiawan
Copy link

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.

@dffxd-suntra
Copy link

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

@Crocsx
Copy link

Crocsx commented Apr 16, 2024

this is still the case I believe today

@HawtinZeng
Copy link

A workaround for temperory:
image

@Kinzi
Copy link

Kinzi commented Jul 23, 2024

@HawtinZeng this worked for me.....

@LukasDzenk
Copy link

@HawtinZeng Worked like a charm. Much appreciated.

@HawtinZeng
Copy link

Maybe we need to endure this bug until Vite api get stable for a while.

@bitdom8
Copy link

bitdom8 commented Aug 16, 2024

Revise the dist again would be painful each time, please resolve this

@ChristopherBull
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests