This repository was archived by the owner on Feb 6, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathgulpfile.js
More file actions
62 lines (54 loc) · 1.75 KB
/
gulpfile.js
File metadata and controls
62 lines (54 loc) · 1.75 KB
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
// Include gulp
var gulp = require('gulp');
// pull in the plugins
$ = require('gulp-load-plugins')({
pattern: ['gulp-*', 'browser-sync']
});
// browser-sync task for starting the server.
gulp.task('browser-sync', function() {
$.browserSync({
proxy: "./"
});
});
// task for reloading the browser
gulp.task('bs-reload', function() {
$.browserSync.reload();
});
// Lint Javascript Task
gulp.task('lint', function() {
return gulp.src('assets/js/*.js')
.pipe($.jshint())
.pipe($.jshint.reporter('default'));
});
// compile, prefix, and minify the sass
gulp.task('styles', function() {
return gulp.src('assets/scss/*.scss')
.pipe($.plumber())
.pipe($.rubySass({ "sourcemap=none": true }))
.pipe($.autoprefixer(["> 1%", "last 2 versions", "Firefox ESR", "Opera 12.1" , "ie 7"], { cascade: true }))
.pipe(gulp.dest('.'))
.pipe($.rename({suffix: '.min'}))
.pipe($.minifyCss())
.pipe(gulp.dest('.'))
.pipe($.browserSync.reload({stream:true}));
});
// Concatenate & Minify JS
gulp.task('scripts', function() {
return gulp.src('assets/js/*.js')
.pipe($.plumber())
.pipe($.sourcemaps.init())
.pipe($.concat('all.min.js'))
.pipe($.uglify())
.pipe($.sourcemaps.write('../maps'))
.pipe(gulp.dest('assets/js/dist'))
.pipe($.browserSync.reload({stream:true}));
});
// Watch Files For Changes
gulp.task('watch', function() {
gulp.watch('assets/js/*.js', ['lint', 'scripts']);
gulp.watch('assets/scss/**/*.scss', ['styles']);
gulp.watch('**/*.html', ['bs-reload']);
gulp.watch('**/*.php', ['bs-reload']);
});
// Default Task
gulp.task('default', ['lint', 'styles', 'scripts', 'browser-sync', 'watch']);