mathisonian / mathisonian/gulp-sri

How would you use this with gulp-inject?

Open
#5 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
15
Forks
3
PR merge metrics
No merged PRs in 30d

Description

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'));
});
```

Contributor guide

Open the contributing guide

Research direction

Start by reading the gulp-sri usage documentation and the gulp-inject transform API, then trace the shown inject-external task from its minified asset sources to the CSHTML destination. A useful outcome would document whether and how these plugins can be combined, including the expected generated markup.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
tooling
Issue type
Documentation
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.