-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
75 lines (63 loc) · 1.67 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
//gulp file by prajkty
var gulp = require('gulp');
var sass = require('gulp-sass');
var browserSync = require('browser-sync').create();
//var cssnano = require('gulp-cssnano');
//var imagemin = require('gulp-imagemin');
var del = require('del');
var runSequence = require('run-sequence');
gulp.task('hello', function() {
console.log('Hello world');
});
gulp.task('sass', function(){
return gulp.src('src/scss/*.scss')
.pipe(sass()) // Using gulp-sass
.pipe(gulp.dest('src/css'))
.pipe(browserSync.reload({
stream: true
}))
});
gulp.task('browserSync', function() {
browserSync.init({
server: {
baseDir: 'src'
},
})
});
gulp.task('useref', function(){
return gulp.src('src/*.html')
.pipe(useref())
//.pipe(gulpIf('*.js', uglify()))
// Minifies only if it's a CSS file
.pipe(gulpIf('*.css', cssnano()))
.pipe(gulp.dest('dist'))
});
// gulp.task('images', function(){
// return gulp.src('src/images/**/*.+(png|jpg|gif|svg)')
// .pipe(imagemin({
// // Setting interlaced to true
// interlaced: true
// }))
// .pipe(gulp.dest('dist/images'))
// });
gulp.task('fonts', function() {
return gulp.src('src/fonts/**/*')
.pipe(gulp.dest('dist/fonts'))
});
gulp.task('clean:dist', function() {
return del.sync('dist');
});
//dev task
gulp.task('serve', ['browserSync', 'sass'], function (){
gulp.watch('src/scss/*.scss', ['sass']);
gulp.watch('src/*.html', browserSync.reload);
gulp.watch('src/js/**/*.js', browserSync.reload);
// Other watchers
});
//final build task
gulp.task('build', function (callback) {
runSequence('clean:dist',
['sass', 'useref', 'images', 'fonts'],
callback
)
});