How to use importmap while developing an extension for chrome

289 Views Asked by At

I am trying to create chrome extension that uses Three.js and some of its plugins and I cannot import them without an importmap as the modules themselves are importing Three.js as 'three' without the path to three.module.js. However, when trying to use an importmap I run into CSP violation as it would be an inline script. Even after adding the lines bellow into my manifest.json (manifest version 3), I still get CSP violations.

"content_security_policy": {
    "script-src": "'self' 'unsafe-inline' 'sha256-InlineScriptHash' 'nonce-NonceAddedToInline'"
  },

How should the "content_security_policy" be changed to allow importmap or how should I go about importing Three.js plugins?

1

There are 1 best solutions below

0
Halvor Sakshaug On

If you add another CSP it can only make the total policy stricter. You will need to identify the existing policy (check response headers and meta tags) and modify it. It could be set in code, framework, web server or a proxy.