mirror of
https://github.com/chanzuckerberg/cellxgene.git
synced 2026-09-30 17:38:11 +08:00
Refactor build and CSP headers for Safari compat (#1442)
* add unsafe-inline directive to style-src * debugging - turn on csp reporting * revert reporting only csp * do not inline JS and CSS in build * enable HTTPs only when in production mode * remove debug printf * fix clean target * revert force_https removal
This commit is contained in:
@@ -14,13 +14,14 @@ class CspHashPlugin {
|
||||
(data, cb) => {
|
||||
const { filename } = this.opts;
|
||||
|
||||
const $ = cheerio.load(data.html, { decodeEntities: false });
|
||||
|
||||
if (filename) {
|
||||
const $ = cheerio.load(data.html, { decodeEntities: false });
|
||||
const results = {};
|
||||
results["script-hashes"] = $("script:not([src])")
|
||||
results["script-hashes"] = $("script:not([src]):not([no-csp-hash])")
|
||||
.map((i, elmt) => this.digest($(elmt).html()))
|
||||
.get();
|
||||
results["style-hashes"] = $("style:not([href])")
|
||||
results["style-hashes"] = $("style:not([href]):not([no-csp-hash])")
|
||||
.map((i, elmt) => this.digest($(elmt).html()))
|
||||
.get();
|
||||
|
||||
@@ -31,6 +32,18 @@ class CspHashPlugin {
|
||||
};
|
||||
}
|
||||
|
||||
// remove no-csp-hash attributes
|
||||
let foundOne = false;
|
||||
$("script[no-csp-hash]").each((i, elmt) => {
|
||||
$(elmt).removeAttr("no-csp-hash");
|
||||
foundOne = true;
|
||||
});
|
||||
$("style[no-csp-hash]").each((i, elmt) => {
|
||||
$(elmt).removeAttr("no-csp-hash");
|
||||
foundOne = true;
|
||||
});
|
||||
if (foundOne) data.html = $.html();
|
||||
|
||||
// Tell webpack to move on
|
||||
cb(null, data);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user