-
Notifications
You must be signed in to change notification settings - Fork 15
/
gulpfile.js
85 lines (72 loc) · 2.08 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
/**
* Created by SQ04 Theophilus Omorebgee <[email protected]> on 6/30/2016.
*/
var gulp = require('gulp');
var browserSync = require('browser-sync').create();
var uglify = require('gulp-uglify');
var rename= require('gulp-rename');
var gutil = require('gulp-util');//to help log any error found in our .js file
var del = require('del');
var runSequence = require('run-sequence');
var cssnano = require('gulp-cssnano');
gulp.task('browserSync', function() {
browserSync.init({
server: {
baseDir: './'
}
})
});
gulp.task('build', function (callback) {
runSequence('clean',
//build in parallel
['build-css', 'build-js'],
callback
)
});
gulp.task('build-css-files', function() {
console.log("Build css");
return gulp.src(['css/product-tour.css'])
.pipe(cssnano().on('error', gutil.log))
.pipe(gulp.dest('dist/css'))
.pipe(rename('product-tour.min.css'))
.pipe(gulp.dest('dist/css'))
.pipe(browserSync.reload({
stream: true
}));
});
gulp.task('build-js-files', function() {
console.log("Build Our js");
return gulp.src(['js/product-tour.js'])
.pipe(uglify().on('error', gutil.log))
.pipe(gulp.dest('dist/js'))
.pipe(rename('product-tour.min.js'))
.pipe(gulp.dest('dist/js'))
.pipe(browserSync.reload({
stream: true
}));
});
gulp.task('build-js', function (callbacks) {
runSequence('build-js-files','clean-js',
callbacks
)
});
gulp.task('build-css', function (callbacks) {
runSequence('build-css-files','clean-css',
callbacks
)
});
gulp.task('clean', function () {
return del.sync('dist');
});
gulp.task('clean-js', function () {
return del.sync('dist/js/product-tour.js');
});
gulp.task('clean-css', function () {
return del.sync('dist/css/product-tour.css');
});
gulp.task('watch',['browserSync'], function(){
gulp.watch('js/*.js', ['build-js']);
gulp.watch('css/*.css', ['build-css']);
gulp.watch('**/*.html', browserSync.reload);
});
gulp.task("serve",['watch']);