-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
114 lines (96 loc) · 2.81 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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
// load the plugins
var gulp = require('gulp'),
sass = require('gulp-sass'),
compass = require('gulp-compass'),
minifyCSS = require('gulp-minify-css'),
concatCSS = require('gulp-concat-css'),
rename = require('gulp-rename'),
jshint = require('gulp-jshint'),
ngAnnotate = require('gulp-ng-annotate'),
concat = require('gulp-concat'),
uglify = require('gulp-uglify'),
nodemon = require('gulp-nodemon'),
imagemin = require('gulp-imagemin'),
livereload = require('gulp-livereload'),
path = require('path');
// task for livereload
gulp.task('html', function() {
return gulp.src(['public/**/*.html'])
.pipe(livereload())
});
// task for sass processing
gulp.task('sass', function() {
return gulp.src('public/assets/sass/style.sass')
.pipe(compass({
project: path.join(__dirname, 'public/assets'),
css: 'css',
sass: 'sass',
font: 'fonts',
style: 'nested'
}))
});
// task for css compiling
gulp.task('css', function() {
return gulp.src(['public/libs/**/*.css', 'public/assets/css/**/*.css'])
.pipe(concatCSS('style.min.css'))
.pipe(minifyCSS())
.pipe(gulp.dest('public/assets'))
.pipe(livereload())
});
// task for lint, minify and concat frontend js files
gulp.task('scripts', function() {
return gulp.src(['public/assets/js/**/*.js'])
.pipe(jshint())
.pipe(jshint.reporter('default'))
.pipe(concat('scripts.min.js'))
.pipe(uglify())
.pipe(gulp.dest('public/assets'))
.pipe(livereload())
});
// task for angular
gulp.task('angular', function() {
return gulp.src(['public/app/**/*.js', '!public/app/app.min.js'])
.pipe(jshint())
.pipe(jshint.reporter('default'))
.pipe(ngAnnotate())
.pipe(concat('app.min.js'))
// .pipe(uglify())
.pipe(gulp.dest('public/app'))
.pipe(livereload())
});
// task for compressing images
gulp.task('img', function() {
return gulp.src('public/assets/img-src/**/*')
.pipe(imagemin())
.pipe(gulp.dest('public/assets/img'))
.pipe(livereload())
});
// task for watching changes
gulp.task('watch', function() {
// using livereload
livereload.listen();
// watch the html files and run html task
gulp.watch('public/**/*.html', ['html']);
// watch the sass files and run compiling
gulp.watch('public/assets/sass/**/*.sass', ['sass']);
// watch the css files and run concat and minifying
gulp.watch('public/assets/css/**/*.css', ['css']);
// watch other js files and run scripts task
gulp.watch('public/assets/js/**/*.js', ['scripts']);
// watch angular and run angular
gulp.watch(['public/app/**/*.js', '!public/app/app.min.js'], ['angular']);
});
// Nodemon
gulp.task('nodemon', function(){
nodemon({
script: 'server.js',
ext: 'js less html'
})
.on('start', ['watch'])
.on('change', ['watch'])
.on('restart', function(){
console.log('Restarted!');
});
});
// the main gulp task
gulp.task('default', ['nodemon']);