fix: removes need for unsafe-eval CSR

This commit is contained in:
Hank Stoever
2020-07-08 05:55:56 -07:00
parent e7b614bb5c
commit 3f62dc5edb
2 changed files with 11 additions and 1 deletions

View File

@@ -8,7 +8,7 @@
"256": "assets/logo-128@2x.png",
"512": "assets/logo-128@3x.png"
},
"content_security_policy": "script-src 'self' 'unsafe-eval'; object-src 'self'",
"content_security_policy": "script-src 'self'<% DEV_CSR %>; object-src 'self'",
"permissions": [
"activeTab"
],

View File

@@ -209,6 +209,16 @@ module.exports = {
from: path.join(sourceRootPath, 'manifest.json'),
to: path.join(distRootPath, 'manifest.json'),
toType: 'file',
transform(content, path) {
const tag = '<% DEV_CSR %>';
content = content.toString();
if (nodeEnv === 'development') {
content = content.replace(tag, " 'unsafe-eval'");
} else {
content = content.replace(tag, '');
}
return Buffer.from(content);
},
},
]),
new webpack.DefinePlugin({