sinanbekar / browser-extension-react-typescript-starter

🚀 React & TypeScript Starter for developing web extensions with hot reload!
MIT License
121 stars 20 forks source link

CSP Issue when running HMR-enabled dev build on Firefox 117.0 #65

Closed CortexPE closed 10 months ago

CortexPE commented 10 months ago

Error messages:

Content-Security-Policy: The page’s settings blocked the loading of a resource at http://localhost:5173/@vite/env (“script-src”).
Content-Security-Policy: The page’s settings blocked the loading of a resource at http://localhost:5173/@crx/client-worker (“script-src”).
Content-Security-Policy: The page’s settings blocked the loading of a resource at http://localhost:5173/background/index.ts (“script-src”).

Popup: image

Steps to reproduce:

  1. npm run dev to build dist and start vite
  2. npm run firefox-mv2-build to build dist-firefox-v2 from HMR-enabled chrome dist
  3. Load unpacked extension at $PROJECT_DIR/dist-firefox-v2/manifest.json via about:debugging#/runtime/this-firefox > Load Temporary Add-on...
  4. Inspect logs via about:debugging#/runtime/this-firefox > [Dev] Browser Extension TypeScript & React Starter > Inspect
sinanbekar commented 10 months ago

For now, you can not use dev build with Firefox and you should only run firefox build after the production builds. This is a missing feature of @crxjs/vite-plugin. As soon as the https://github.com/crxjs/chrome-extension-tools/pull/790 is npm published (merged but not published), I will add support for Firefox MV3 production build support. related https://github.com/sinanbekar/browser-extension-react-typescript-starter/issues/61.

I am closing this but feel free to open a issue for other problems.