-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
35 lines (30 loc) · 1023 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
var Elixir = require('laravel-elixir');
var sri = require('gulp-sri');
Elixir.extend('sri', function (src, output, options) {
var filename = options && options.fileName;
new Elixir.Task('sri', function () {
this.recordStep('Generating hashes');
return (
gulp.src(this.src.path, { base: Elixir.config.publicPath })
.pipe(sri(options))
.pipe(gulp.dest(this.output.baseDir))
.pipe(new Elixir.Notification('SRI complete!'))
);
}, getPaths(src, output, filename));
});
/**
* Prep the Gulp src and output paths.
*
* @param {string|array} src
* @param {string|null} output
* @param {string|null} filename
* @return {object}
*/
function getPaths(src, output, filename) {
src = Array.isArray(src) ? src : [src];
output = output || Elixir.config.publicPath;
filename = filename || 'sri.json';
return new Elixir.GulpPaths()
.src(src, Elixir.config.publicPath)
.output(output, filename);
}