-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgulpfile.js
116 lines (107 loc) · 3.68 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
115
116
// Include gulp and plugins
var gulp = require('gulp'),
autoprefixer = require('gulp-autoprefixer'),
sass = require('gulp-sass'),
neat = require('node-neat').includePaths,
concat = require('gulp-concat'),
uglify = require('gulp-uglify'),
gutil = require('gulp-util'),
newer = require('gulp-newer'),
imagemin = require('gulp-imagemin'),
svgo = require('gulp-svgo'),
ngAnnotate = require('gulp-ng-annotate'),
plumber = require('gulp-plumber'),
notify = require("gulp-notify"),
rename = require('gulp-rename');
// Error Handling
var onError = function(err) {
// Notfiy (message and sound)
notify.onError({
title: "Gulp",
subtitle: "Failure!",
message: "Error: <%= error.message %>",
sound: "Funk"
})(err);
this.emit('end');
};
// Compile Our Sass
gulp.task('sass', function() {
return gulp.src('assets/css/scss/**/*.scss')
.pipe(plumber({errorHandler: onError}))
.pipe(sass({
includePaths: ['styles'].concat(neat)
}))
.pipe(autoprefixer('last 2 version'))
.pipe(gulp.dest('src/public/dist/css'));
});
gulp.task('angular', function() {
return gulp.src(['assets/js/app/**/*.js'])
.pipe(plumber({errorHandler: onError}))
.pipe(ngAnnotate())
// disabling for now while debugging
// .pipe(uglify())
.pipe(gulp.dest('src/public/dist/js/app'))
});
// Concatenate & Minify JS
gulp.task('scripts', function() {
// Gather our files
gulp.src([
'assets/js/vendors/modernizr/modernizr.min.js',
'assets/js/vendors/jquery/jquery.min.js',
'assets/js/vendors/angularjs/angular.js'
])
.pipe(concat('head.min.js'))
.pipe(ngAnnotate())
.pipe(gulp.dest('src/public/dist/js'));
return gulp.src([
'assets/js/vendors/angular-file-upload/*.js',
'assets/js/vendors/text-angular/*.js',
'assets/js/vendors/*.js',
'assets/js/init.js',
'assets/js/app/services/util.js',
'assets/js/app/services/alert.js',
'assets/js/app/controllers/AlertCtrl.js',
'assets/js/app/directives/dt-events.js'
])
.pipe(concat('scripts.min.js'))
.pipe(ngAnnotate())
// disabling for now while debugging
// .pipe(uglify())
.pipe(gulp.dest('src/public/dist/js'));
});
// Optimize images
gulp.task('images', function() {
return gulp.src('assets/img/**/*')
.pipe(newer('img'))
//.pipe(imagemin())
.pipe(gulp.dest('src/public/dist/img'));
});
// Optimize svg
gulp.task('svg', function() {
return gulp.src('assets/img/**/*.svg')
.pipe(svgo())
.pipe(gulp.dest('src/public/dist/img'))
});
// Copy fonts
gulp.task('fonts', function() {
return gulp.src('assets/css/fonts/*')
// .pipe(newer('img'))
//.pipe(imagemin())
.pipe(gulp.dest('src/public/dist/css/fonts/'));
});
// Watch Files For Changes
gulp.task('watch', function() {
var root = 'assets/'
gulp.watch(root + 'js/vendors/angular.js', ['scripts']);
gulp.watch(root + 'js/vendors/angular-file-upload/*.js', ['scripts']);
gulp.watch(root + 'js/vendors/*.js', ['scripts']);
gulp.watch(root + 'js/init.js', ['scripts']);
gulp.watch(root + 'js/app/**/*.js', ['angular']);
gulp.watch(root + 'css/scss/**/*.scss', ['sass']);
gulp.watch(root + 'img/**/*.jpg', ['images']);
gulp.watch(root + 'img/**/*.png', ['images']);
gulp.watch(root + 'img/**/*.svg', ['svg']);
gulp.watch(root + 'css/fonts/*', ['fonts']);
});
// Default Task
gulp.task('default', ['sass', 'angular', 'scripts', 'images', 'svg', 'fonts']); //