/
gulpfile.js
62 lines (56 loc) · 1.93 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
/*
* The MIT License (MIT)
* Copyright (c) 2017 Kundan Singh
* https://kundan.me
*
*/
var gulp = require('gulp');
var sass = require('gulp-sass'); // sass compiler
var plumber = require('gulp-plumber'); // helps prevent pipe breaking
var csso = require('gulp-csso');
var uncss = require('gulp-uncss');
var uglify = require('gulp-uglify');
var concat = require('gulp-concat');
var templateCache = require('gulp-angular-templatecache');
gulp.task('sass', function() {
gulp.src('public/stylesheets/style.scss')
.pipe(plumber())
.pipe(sass())
.pipe(uncss({
html: [
'public/index.html',
'public/views/add.html',
'public/views/detail.html',
'public/views/home.html',
'public/views/login.html',
'public/views/signup.html'
]
}))
.pipe(csso())
.pipe(gulp.dest('public/stylesheets'));
});
gulp.task('compress', function() {
gulp.src([
'public/vendor/angular.js',
'public/vendor/*.js',
'public/app.js',
'public/services/*.js',
'public/controllers/*.js',
'public/filters/*.js',
'public/directives/*.js'
])
.pipe(concat('app.min.js'))
.pipe(uglify())
.pipe(gulp.dest('public'));
});
gulp.task('templates', function() {
gulp.src('public/views/**/*.html')
.pipe(templateCache({ root: 'views', module: 'MyApp' }))
.pipe(gulp.dest('public'));
});
gulp.task('watch', function() {
gulp.watch('public/stylesheets/*.scss', ['sass']); // watch for any changes in scss file
gulp.watch('public/views/**/*.html', ['templates']);
gulp.watch(['public/**/*.js', '!public/app.min.js', '!public/templates.js', '!public/vendor'], ['compress']);
});
gulp.task('default', ['sass', 'compress', 'templates', 'watch']);