How to configure webpack for implementing CSP

Viewed 100

I currently have a Web Application with Django and React. Started implementing CSP from django and everything going well untill now, added all sources of external scripts. Im currently bumping to this webpack problem: First we weren't using devtools options, and in that way, the code was build using eval(). eg;

/***/ (function(module, exports) {

eval("function _arrayLikeToArray(arr, len) {
  if (len == null || len > arr.length) len = arr.length;\n\n  for (var i = 0, arr2 = new Array(len); i < len; i++) ... 
and evals like that

methods everywhere on the production code. Since CSP doesn't allow to safelly use eval expressions (and I dont want to use unsafe-eval option because damages the security), I saw this github thread to use devtool: source-map for bundling without the eval expressions.

When I rebuild my code, the problem is still occuring. The rebuild code:

"build:dev": "cross-env NODE_ENV=production INDEX_FILE=dev webpack --mode production --progress --colors --config webpack/webpack.config.prod.js"

The devtool config is inside this webpack.config.prod.js file.

What should I do?

0 Answers
Related