How would you use this with gulp-inject?
aligneddev opened this issue · 0 comments
aligneddev commented
I want to automatically add the sri integrity attribute after I've created my minified js/css files, but before I inject it into my cshtml.
I'm struggling to add gulp-sri
into this process. Any help or suggestions would be appreciated.
Thanks!
gulp.task('inject-external',
function () {
var target = gulp.src('./Views/Shared/_ExternalLayout.cshtml');
var sources = gulp.src([distJsFolder + 'lib*.min.js', distJsFolder + 'app*min.js', distCssFolder + 'lib*.min.css', distSvgFolder + '*.min.css', distCssFolder + 'app*.min.css'], {
read: false
});
return target
.pipe(inject(sources, {
transform: function (filepath) {
//Delete wwwroot
for (var i = 0; i < arguments.length; i++) {
if (typeof (arguments[i]) === 'string')
arguments[i] = arguments[i].replace("/wwwroot", '');
}
return inject.transform.apply(inject.transform, arguments);
}
})
)
.pipe(gulp.dest('./Views/Shared'));
});