-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
136 lines (115 loc) · 3.03 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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
'use strict';
// Generated on 2014-03-22 using generator-gulp-webapp 0.0.4
var gulp = require('gulp');
var wiredep = require('wiredep').stream;
// Load plugins
var $ = require('gulp-load-plugins')();
// Styles
gulp.task('styles', function () {
return gulp.src('app/styles/main.scss')
.pipe($.rubySass({
style: 'expanded',
loadPath: ['app/bower_components']
}))
.pipe($.autoprefixer('last 1 version'))
.pipe(gulp.dest('app/styles'))
.pipe($.size());
});
// Scripts
gulp.task('scripts', function () {
return gulp.src('app/scripts/**/*.js')
.pipe($.jshint('.jshintrc'))
.pipe($.jshint.reporter('default'))
.pipe($.size());
});
// HTML
gulp.task('html', ['styles', 'scripts'], function () {
var jsFilter = $.filter('**/*.js');
var cssFilter = $.filter('**/*.css');
gulp.src('app/{,views/}*.html')
.pipe($.useref.assets())
.pipe(jsFilter)
.pipe($.ngmin())
.pipe($.uglify({
mangle: false
}))
.pipe(jsFilter.restore())
.pipe(cssFilter)
.pipe($.csso())
.pipe(cssFilter.restore())
.pipe($.useref.restore())
.pipe($.useref())
.pipe(gulp.dest('dist'))
.pipe($.size());
gulp.src(['app/bower_components/bootstrap-sass/vendor/assets/fonts/bootstrap/*', 'app/fonts/*'])
.pipe(gulp.dest('dist/fonts'));
});
// Images
gulp.task('images', function () {
return gulp.src('app/images/**/*')
.pipe($.cache($.imagemin({
optimizationLevel: 3,
progressive: true,
interlaced: true
})))
.pipe(gulp.dest('dist/images'))
.pipe($.size());
});
// Clean
gulp.task('clean', function () {
return gulp.src(['dist'], { read: false }).pipe($.clean());
});
// Copy
gulp.task('copy', function () {
return gulp.src(['app/CNAME', 'app/robots.txt'])
.pipe(gulp.dest('dist'));
});
// Build
gulp.task('build', ['copy', 'styles', 'html', 'images']);
// Default task
gulp.task('default', ['clean'], function () {
gulp.start('build');
});
// Connect
gulp.task('connect', $.connect.server({
root: ['app'],
port: 9000,
livereload: true
}));
// Inject Bower components
gulp.task('wiredep', function () {
gulp.src('app/styles/*.scss')
.pipe(wiredep({
directory: 'app/bower_components',
ignorePath: 'app/bower_components/'
}))
.pipe(gulp.dest('app/styles'));
gulp.src('app/{,views/}*.html')
.pipe(wiredep({
directory: 'app/bower_components',
ignorePath: 'app/',
exclude: ['bootstrap-sass']
}))
.pipe(gulp.dest('app'));
});
// Watch
gulp.task('watch', ['connect'], function () {
// Watch for changes in `app` folder
gulp.watch([
'app/*.html',
'app/styles/**/*.css',
'app/scripts/**/*.js',
'app/images/**/*'
], function (event) {
return gulp.src(event.path)
.pipe($.connect.reload());
});
// Watch .scss files
gulp.watch('app/styles/**/*.scss', ['styles']);
// Watch .js files
gulp.watch('app/scripts/**/*.js', ['scripts']);
// Watch image files
gulp.watch('app/images/**/*', ['images']);
// Watch bower files
gulp.watch('bower.json', ['wiredep']);
});