Using js in a Chrome extension

I follow this guide to create a new Chrome extension for tabs. Https://facebook.imtqy.com/react/docs/tutorial.html

but when i attach

<script src="https://cdnjs.cloudflare.com/ajax/libs/babel-core/5.8.23/browser.min.js"></script> 

to render JSX using babel as suggested in the manual, I get this error from the browser console.

"browser.min.js: 4 Uncaught EvalError: Refused to evaluate the string as JavaScript because unsafe-eval is not a valid script source in the following content security policy directive: script-src 'self' blob: filesystem: chrome-extension-resource:" " error screenshot

I know this violates the CSP directive, but then again, how can I use the latest version of responseJS using babel?

+12
javascript google-chrome google-chrome-extension reactjs babeljs
source share
2 answers

In manifest.json you can try installing

 "content_security_policy": "script-src 'self' 'unsafe-eval'; object-src 'self'" 

I got a response from here . This saved me the error, but I'm not sufficiently aware of this to find out about other consequences, sorry.

+33
source share

For everyone who comes here, Bruno's answer is more correct. Use the production mode. For example, in the corner

ng build --prod

0
source share

All Articles