guocaoyi / create-chrome-ext

🍺 Scaffolding your Chrome extension! Boilerplates: react \ vue \ svelte \ solid \ preact \ alpine \ lit \ stencil \ inferno \ vanilla
MIT License
1.64k stars 118 forks source link

Content Security Policy Issue #93

Open trungpv1601 opened 2 weeks ago

trungpv1601 commented 2 weeks ago

Anyone face with this issue in Google Chrome Canary v130

content-script-loader.chunk-1f004067.310380a0.js:7 Refused to load the script 'chrome-extension://xxx/assets/chunk-1f004067.js' because it violates the following Content Security Policy directive: "script-src 'self' 'wasm-unsafe-eval' 'inline-speculation-rules' http://localhost:* http://127.0.0.1:*". Note that 'script-src-elem' was not explicitly set, so 'script-src' is used as a fallback.
TypeError: Failed to fetch dynamically imported module: chrome-extension://xxx/assets/chunk-1f004067.js

Make sure you use Google Chrome Canary v130

CleanShot 2024-09-14 at 12 02 22@2x

Thank you

trungpv1601 commented 2 weeks ago

My solution for build production

remove chrome.runtime.getURL in content script

(function () {
  'use strict';

  (async () => {
    await import("./chunk-b674a675.js");
  })().catch(console.error);

})();

More Info here: https://github.com/crxjs/chrome-extension-tools/issues/918