-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathindex.js
33 lines (25 loc) · 1.06 KB
/
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
var path = require('path');
var gulp = require('gulp');
var Elixir = require('laravel-elixir');
var util = require('gulp-util');
var $ = require('gulp-load-plugins')();
var Task = Elixir.Task;
Elixir.extend('useref', function(config, opts) {
config = config || {};
opts = opts || {};
config.baseDir = config.baseDir || 'resources/views';
config.src = config.src || false;
config.searchLevel = config.searchLevel || '**/*.php';
config.outputDir = config.outputDir || 'public';
config.minifyJs = 'minifyJs' in config ? !!config.minifyJs : true;
config.minifyCss = 'minifyCss' in config ? !!config.minifyCss : true;
new Task('useref', function() {
var src = path.join(config.baseDir, !!config.src ? config.src : config.searchLevel);
return gulp.src(src)
.pipe(useref(opts))
.pipe(config.minifyJs ? $.if('**/*.js', $.uglify()) : util.noop())
.pipe(config.minifyCss ? $.if('**/*.css', $.csso()) : util.noop())
.pipe(gulp.dest(config.outputDir))
.pipe($.size());
});
});