-
Notifications
You must be signed in to change notification settings - Fork 1
/
gulpfile.js
67 lines (54 loc) · 1.41 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
var gulp=require('gulp'),
sass=require('gulp-sass')
browserSync = require('browser-sync').create()
cssnano = require('gulp-cssnano')
useref = require('gulp-useref');
var uglify = require('gulp-uglify');
var gulpIf = require('gulp-if');
var wiredep = require('wiredep').stream;
//test gulp
gulp.task('hello', function() {
console.log('Hello Zell');
});
//copy images
gulp.task('imgcopy',function(){
return gulp.src(['app/img/*.*','app/img/**/*.*'])
.pipe(gulp.dest('dist/img/'))
})
//copy fonts
gulp.task('fontcopy',function(){
return gulp.src(['app/fonts/*.*'])
.pipe(gulp.dest('dist/fonts/'))
})
//sass task
gulp.task('sass',function(){
return gulp.src('app/css/*.scss')
.pipe(sass())
.pipe(gulp.dest('app/css/'))
.pipe(browserSync.reload({
stream: true
}))
})
//broweser sync task
gulp.task('browserSync', function() {
browserSync.init({
server: {
baseDir: 'app'
},
})
})
//uglify and minify
gulp.task('useref', function(){
return gulp.src('app/*.html')
.pipe(useref())
// Minifies only if it's a JavaScript file
.pipe(gulpIf('*.js', uglify()))
//.pipe(gulpIf('*.css', cssnano()))
.pipe(gulp.dest('dist'))
});
//watch task
gulp.task('watch', ['browserSync','sass'],function(){
gulp.watch('app/css/*.scss',['sass']);
gulp.watch('app/*.html',browserSync.reload)
gulp.watch('app/js/*.js',browserSync.reload)
})