Chrome extension compiled by Webpack throws `unsafe-eval` error

后端 未结 5 1169
梦如初夏
梦如初夏 2020-12-08 10:16

I get this error when reloading my Chrome Extension after compiling using Webpack:

Uncaught EvalError: Refused to evaluate a string as JavaScript because \'un         


        
5条回答
  •  感动是毒
    2020-12-08 10:57

    A chrome extension is not allowed to use unsafe-eval, or eval at all in fact.

    https://developer.mozilla.org/en-US/Add-ons/WebExtensions/Content_Security_Policy

    When making a Chrome extension understand that it's severely limited by Content Security Policies. Make sure you read and understand the WebExtensions Content Security Policy. If you want to have an inline script like:

    
    

    You're gonna have to calculate the script tags contents into its SHA256 value and add that to your manifest in order for it to be allowed to be executed.

提交回复
热议问题