Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How would you use this with gulp-inject? #5

Open
aligneddev opened this issue Jul 20, 2018 · 0 comments
Open

How would you use this with gulp-inject? #5

aligneddev opened this issue Jul 20, 2018 · 0 comments

Comments

@aligneddev
Copy link

aligneddev commented Jul 20, 2018

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'));
    });
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant