when struggling with converting a jQuery based Chrome app to Vue. Because of Chrome Apps’ Content Security Policy (CSP) it is not possible to use eval() and thus compiling templates must be done beforehand.
That itself is not a problem with Vue’s Single File Components (SFC) approach where all templates get compiled to render functions in the build process.
However, since the build target is production all warnings and helpful comments from vue.js are stripped off. So for example, if I forget a property for a component, I get not warning about it. It just won’t show up. That makes development very difficult.
Then, if I in package.json for build use:
“build”: “vue-cli-service build –mode development”
I get an error in the Chrome app:
Uncaught EvalError: Refused to evaluate a string as JavaScript because ‘unsafe-eval’ is not an allowed source of script in the following Content Security Policy directive: “script-src ‘self’ blob: filesystem: chrome-extension-resource: ‘wasm-eval’”.
And there are indeed a lot of evals in the index.js file starting with
eval(“__webpack_require_
So my question is:
How do I make the build system preserve warnings and hints in the console without using the forbidden eval’s?
when not sure if the problem is caused by the template compiler being included, but if so, how do I tell the builder not to use the compiler but still use development mode?
Solution :
It is an “issue” with the CSP, you need to use the vue.runtime.js version of Vue.
Please refer to https://vuejs.org/v2/guide/installation.html#CSP-environments