-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
85 lines (74 loc) · 2.09 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
// Include gulp
var gulp = require('gulp');
// Include Our Plugins
var jshint = require('gulp-jshint');
var sass = require('gulp-sass');
var cssnano = require('gulp-cssnano');
var concat = require('gulp-concat');
var uglify = require('gulp-uglify');
var rename = require('gulp-rename');
var minifyHTML = require('gulp-minify-html');
var browserSync = require('browser-sync').create();
// Lint Task
gulp.task('lint', function() {
return gulp.src('app/js/*.js')
.pipe(jshint())
.pipe(jshint.reporter('default'));
});
//SASS
gulp.task('sass', function() {
return gulp.src('app/css/*.scss')
.pipe(sass())
.pipe(gulp.dest('dist/css'))
.pipe(browserSync.reload({
stream: true
}))
});
gulp.task('browserSync', function() {
browserSync.init({
server: {
baseDir: 'dist'
},
})
})
// Concatenate & Minify JS
gulp.task('scripts', function() {
return gulp.src('app/js/*.js')
.pipe(concat('all.js'))
.pipe(gulp.dest('dist'))
.pipe(rename('all.min.js'))
.pipe(uglify())
.pipe(gulp.dest('dist'));
});
//Minify css
//gulp.task('minify-css', function() {
// return gulp.src('dist/css/style.css')
// .pipe(cssnano())
// .pipe(gulp.dest('dist/css/style.min.css'));
//});
// Watch Files For Changes
gulp.task('watch',['browserSync', 'sass'], function() {
gulp.watch('app/js/*.js', ['lint', 'scripts']);
gulp.watch('app/css/*.scss', ['sass']);
gulp.watch('app/tpl/*.html', ['minify-tpl']);
gulp.watch('app/index.html', ['minify-html']);
});
//minify html
gulp.task('minify-html', function() {
return gulp.src('app/*.html')
.pipe(minifyHTML({ empty: true }))
.pipe(gulp.dest('dist'));
});
//minify tpl
gulp.task('minify-tpl', function() {
return gulp.src('app/tpl/*.html')
.pipe(minifyHTML({ empty: true }))
.pipe(gulp.dest('dist'));
});
//copy bower_components
gulp.task('copy-bower', function(){
gulp.src('bower_components/**')
.pipe(gulp.dest('dist/bower_components'));
});
// Default Task
gulp.task('default', ['lint', 'minify-html', 'minify-tpl', 'copy-bower', 'scripts', 'watch']);