Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 15 additions & 13 deletions Gulpfile.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
/* eslint-disable */
const gulp = require('gulp');
const sri = require('gulp-sri');
const hashsum = require('gulp-hashsum');
const through = require('through2');
const fs = require('fs');
const path = require('path');
const git = require('git-rev-sync');
const pkg = require('./package.json');
const { upload } = require('gulp-s3-publish');
Expand Down Expand Up @@ -118,19 +121,18 @@ const canBeDeployedProd = async () => {

// GENERATE SRI TAG
gulp.task('sri', () => {
return gulp.src(sourceSRI)
.pipe(sri({
fileName: 'dist/manifest.json',
transform: (o) => {
let newOb = {};
for (const el in o) {
newOb[el.replace('dist/', '')] = { sri: o[el] };
};

return newOb;
}
const manifest = {};

return gulp.src(sourceSRI) // adjust to your `sourceSRI`
.pipe(hashsum({ hash: 'sha384', json: false }))
.pipe(through.obj((file, _, cb) => {
const fileName = path.relative('dist', file.relative);
manifest[fileName] = { sri: file.contents.toString() };
cb(null, file);
}))
.pipe(gulp.dest('.'));
.on('end', () => {
fs.writeFileSync('dist/manifest.json', JSON.stringify(manifest, null, 2));
});
});

// DEPLOYMENTS
Expand Down
Loading