Skip to content

Commit b28e080

Browse files
rawana90Celestial
and
Celestial
authored
React upgrade fixes (#148)
* microbundle-crl replaced with microbundle to address the microbundle-crl vulnerabilities * gulp-sri replaced with gulp-hashsum and through2 --------- Co-authored-by: Celestial <[email protected]>
1 parent 80a0be0 commit b28e080

File tree

4 files changed

+1280
-4155
lines changed

4 files changed

+1280
-4155
lines changed

Gulpfile.js

+15-13
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
/* eslint-disable */
22
const gulp = require('gulp');
3-
const sri = require('gulp-sri');
3+
const hashsum = require('gulp-hashsum');
4+
const through = require('through2');
5+
const fs = require('fs');
6+
const path = require('path');
47
const git = require('git-rev-sync');
58
const pkg = require('./package.json');
69
const { upload } = require('gulp-s3-publish');
@@ -118,19 +121,18 @@ const canBeDeployedProd = async () => {
118121

119122
// GENERATE SRI TAG
120123
gulp.task('sri', () => {
121-
return gulp.src(sourceSRI)
122-
.pipe(sri({
123-
fileName: 'dist/manifest.json',
124-
transform: (o) => {
125-
let newOb = {};
126-
for (const el in o) {
127-
newOb[el.replace('dist/', '')] = { sri: o[el] };
128-
};
129-
130-
return newOb;
131-
}
124+
const manifest = {};
125+
126+
return gulp.src(sourceSRI) // adjust to your `sourceSRI`
127+
.pipe(hashsum({ hash: 'sha384', json: false }))
128+
.pipe(through.obj((file, _, cb) => {
129+
const fileName = path.relative('dist', file.relative);
130+
manifest[fileName] = { sri: file.contents.toString() };
131+
cb(null, file);
132132
}))
133-
.pipe(gulp.dest('.'));
133+
.on('end', () => {
134+
fs.writeFileSync('dist/manifest.json', JSON.stringify(manifest, null, 2));
135+
});
134136
});
135137

136138
// DEPLOYMENTS

0 commit comments

Comments
 (0)