-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
88 lines (73 loc) · 2.24 KB
/
gulpfile.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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
var gulp = require('gulp'),
sass = require('gulp-sass'),
minify = require('gulp-minify-css'),
concat = require('gulp-concat'),
uglify = require('gulp-uglify'),
rename = require('gulp-rename'),
notify = require('gulp-notify'),
growl = require('gulp-notify-growl'),
phpunit = require('gulp-phpunit'),
livereload = require('gulp-livereload'),
lr = require('tiny-lr'),
print = require('gulp-print'),
rev = require('gulp-rev'),
del = require('del'),
util = require('gulp-util'),
autoprefix = require('gulp-autoprefixer'),
server = lr();
var paths = {
'css': './public/css/',
'js': './public/js/'
};
var styles = [
'./resources/assets/sass/site.scss'
];
var scripts = [
'./resources/assets/js/site.js'
];
function handleError(err) {
util.log(util.colors.red(err.toString()));
this.emit('end');
}
gulp.task('cleanup', function() {
return del('./public/build/*', { force: true });
});
gulp.task('css', ['cleanup'], function() {
return gulp.src(styles)
.pipe(sass())
.on('error', handleError)
.pipe(autoprefix('last 2 versions'))
.pipe(gulp.dest(paths.css))
.pipe(livereload())
.pipe(minify())
.pipe(rename({suffix: '.min'}))
.pipe(rev())
.pipe(gulp.dest('./public/build'))
.pipe(rev.manifest())
.pipe(gulp.dest('./public/build'));
});
gulp.task('scripts', function() {
return gulp.src(scripts)
.pipe(gulp.dest(paths.js))
.pipe(rename({suffix: '.min'}))
.pipe(uglify({preserveComments: 'some'}))
.pipe(gulp.dest(paths.js));
});
gulp.task('app', function() {
return gulp.src("./public/app/**/*.js")
.pipe(concat("app.js"))
.pipe(gulp.dest(paths.js))
.pipe(livereload());
})
gulp.task('blade', function() {
return gulp.src("./public/index.php")
.pipe(livereload());
});
gulp.task('watch', ['default'], function() {
livereload.listen();
gulp.watch('./resources/assets/js/**/*.js', ['scripts']);
gulp.watch('./resources/assets/sass/**/*.scss', ['css']);
gulp.watch('./resources/views/**/*.blade.php', ['blade']);
gulp.watch('./public/app/**', ['app', 'blade']);
});
gulp.task('default', ['css', 'scripts', 'app']);