-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
107 lines (94 loc) · 3.19 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
var gulp = require('gulp');
var sass = require('gulp-sass');
var autoprefixer = require('gulp-autoprefixer');
var concat = require('gulp-concat');
var uglify = require('gulp-uglify');
var watch = require('gulp-watch');
var newer = require('gulp-newer');
var ngannotate = require('gulp-ng-annotate');
var imagemin = require('gulp-imagemin');
gulp.task('default', ['js_libs', 'js_app', 'sass'], function(){
gulp.watch('assets/js/**/*.js', ['js_libs', 'js_app']);
gulp.watch('assets/sass/**/*.scss', ['sass']);
});
gulp.task('js_libs', function(){
return gulp
.src([
'assets/js/libs/jquery/dist/jquery.js',
'assets/js/libs/angular/angular.js',
'assets/js/libs/angular-route/angular-route.js',
])
.pipe(concat('vendors.js'))
.pipe(ngannotate())
.pipe(uglify())
.pipe(gulp.dest('assets/js/dist'))
});
gulp.task('js_app', function(){
return gulp.src(['assets/js/app/config.js', 'assets/js/app/services/*.js', 'assets/js/app/controllers/*.js'])
.pipe(concat('app.js'))
.pipe(ngannotate())
.pipe(uglify())
.pipe(gulp.dest('assets/js/dist'))
});
// Compile Sass into CSS & auto-inject into browsers
gulp.task('sass', function() {
return gulp.src('assets/sass/**/*.scss')
.pipe(sass({outputStyle: 'nested'}).on('error', sass.logError))
.pipe(autoprefixer({
browsers: ['last 2 versions']
}))
.pipe(gulp.dest('assets/css/'))
});
//*************//
// PROD TASKS //
//***********//
gulp.task('prod', ['img_prod','css_prod','js_libs_prod','js_app_prod','sass_prod','bower_prod','views_prod','index_prod'], function(){});
gulp.task('img_prod',function(){
return gulp.src('assets/img/**/*')
.pipe(newer('prod/assets/img/'))
.pipe(imagemin())
.pipe(gulp.dest('prod/assets/img/'))
});
gulp.task('css_prod', function(){
return gulp.src('assets/css/normalize.css')
.pipe(gulp.dest('prod/assets/css/'))
});
gulp.task('sass_prod',function(){
return gulp.src('assets/sass/**/*.scss')
.pipe(sass({outputStyle: 'compressed'}).on('error', sass.logError))
.pipe(autoprefixer({
browsers: ['last 2 versions']
}))
.pipe(gulp.dest('prod/assets/css/'))
});
gulp.task('js_libs_prod', function(){
return gulp
.src([
'assets/js/libs/jquery/dist/jquery.js',
'assets/js/libs/angular/angular.js',
'assets/js/libs/angular-route/angular-route.js',
])
.pipe(concat('vendors.js'))
.pipe(ngannotate())
.pipe(uglify())
.pipe(gulp.dest('prod/assets/js/dist'))
});
gulp.task('js_app_prod', function(){
return gulp.src('assets/js/app/*.js')
.pipe(concat('app.js'))
.pipe(ngannotate())
.pipe(uglify())
.pipe(gulp.dest('prod/assets/js/dist'))
});
gulp.task('bower_prod',function(){
return gulp.src('bower_components/**/*')
.pipe(gulp.dest('prod/bower_components/'))
});
gulp.task('views_prod',function(){
return gulp.src('views/**/*')
.pipe(gulp.dest('prod/views/'))
});
gulp.task('index_prod',function(){
return gulp.src(['index.html','.htaccess'])
.pipe(gulp.dest('prod/'))
});