Fix content script build and chrome.storage errors#9
Conversation
- Build content script as IIFE format (not ES modules) using separate vite config - Add chrome.storage availability check in logger to prevent errors in content scripts - Update package.json build script to run both vite builds
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| 'profile-renderer': resolve(__dirname, 'src/profile/profile-renderer.html'), | ||
| offscreen: resolve(__dirname, 'src/offscreen/offscreen.html'), | ||
| background: resolve(__dirname, 'src/background/background.ts'), |
There was a problem hiding this comment.
Dev build no longer emits content script
The main Vite config now omits the content script from rollupOptions.input, but npm run dev (and any watch build using the default config) still relies solely on this file. Running the documented dev build now produces a dist without content.js, so the extension fails to load its content script when loaded in Chrome even though the manifest still references it.
Useful? React with 👍 / 👎.
Summary
Problem
Content scripts were failing with:
Solution
vite.content.config.tsto build content script as IIFE formatisStorageAvailablecheck in logger before accessing chrome.storage.localTest Plan