-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
167 lines (149 loc) · 4 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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
'use strict';
/**
* Import plugins
*/
var gulp = require('gulp'),
$ = require('gulp-load-plugins')(),
browserSync = require('browser-sync'),
reload = browserSync.reload,
runSequence = require('run-sequence'),
argv = require('yargs').argv,
del = require('del');
/**
* Build vendors dependencies
*/
gulp.task('vendors', function() {
/**
* CSS VENDORS
*/
gulp.src([
''
])
.pipe($.concat('vendors.css'))
.pipe($.minifyCss())
.pipe(gulp.dest('public/css'));
/**
* JS VENDORS
* (with jQuery and Bootstrap dependencies first)
*/
gulp.src([
'bower_components/angular/angular.js',
'bower_components/angular-strap/dist/angular-strap.js',
'bower_components/angular-strap/dist/angular-strap.tpl.js',
'bower_components/angular-messages/angular-messages.js',
'bower_components/angular-resource/angular-resource.js',
'bower_components/angular-route/angular-route.js',
'bower_components/angular-cookies/angular-cookies.js',
'bower_components/moment/moment.js'
])
.pipe($.concat('vendors.min.js'))
.pipe($.uglify())
.pipe(gulp.dest('public/js'));
/**
* FONTS SOURCES
* Important to add the bootstrap fonts to avoid issues with the fonts include path
*/
gulp.src([
'bower_components/bootstrap-sass-official/assets/fonts/bootstrap/*',
'assets/fonts/*'
])
.pipe(gulp.dest('public/fonts'));
/**
* POLYFILLS SOURCES
* Various polyfills required for old IE
*/
gulp.src([
'bower_components/html5shiv/dist/html5shiv.js',
'bower_components/respond/dest/respond.src.js'
])
.pipe($.concat('polyfills.min.js'))
.pipe($.uglify())
.pipe(gulp.dest('public/js'));
});
/**
* Build styles from SCSS files
* With error reporting on compiling (so that there's no crash)
*/
gulp.task('styles', function() {
if (argv.production) { console.log('Processing styles for production env.' ); }
return gulp.src('assets/sass/tsm.scss')
.pipe($.rubySass())
.on('error', $.notify.onError(function (error) {
console.log(error.message);
if (!argv.production) {
return 'Message to the notifier: ' + error.message;
}
}))
.pipe($.autoprefixer('last 2 version', 'safari 5', 'ie 8', 'ie 9', 'ff 27', 'opera 12.1'))
.pipe($.minifyCss())
.pipe(gulp.dest('public/css'));
});
/**
* Build JS
* With error reporting on compiling (so that there's no crash)
* And jshint check to highlight errors as we go.
*/
gulp.task('scripts', function() {
return gulp.src([
'assets/js/app.js',
'assets/js/controllers/main.js',
'assets/js/controllers/add.js',
'assets/js/services/show.js',
])
.pipe($.jshint())
.pipe($.jshint.reporter('jshint-stylish'))
.pipe($.concat('main.js'))
.pipe(gulp.dest('public/js'))
.pipe($.rename({ suffix: '.min' }))
.pipe($.uglify())
.pipe(gulp.dest('public/js'));
});
/**
* Build Hologram Styleguide
*/
gulp.task('styleguide', function () {
return gulp.src('hologram_config.yml')
.pipe($.hologram());
});
/**
* Clean output directories
*/
gulp.task('clean', del.bind(null, ['build', 'styleguide']));
/**
* Serve
*/
gulp.task('serve', ['styles', 'scripts'], function () {
browserSync({
server: {
baseDir: ['public'],
},
open: false
});
gulp.watch(['styleguide/*.html'], reload);
gulp.watch(['assets/sass/**/*.scss'], function() {
runSequence('styles', 'styleguide', reload);
});
gulp.watch(['assets/js/**/*.js'], function() {
runSequence('scripts', reload);
});
});
/**
* Deploy to GH pages
*/
gulp.task('deploy', function () {
gulp.src("styleguide/**/*")
.pipe($.ghPages());
});
/**
* Task to build assets on production server
*/
gulp.task('production',['clean'], function() {
argv.production = true;
runSequence('vendors', 'styles', 'scripts');
});
/**
* Default task
*/
gulp.task('default', ['clean'], function(cb) {
runSequence('vendors', 'styles', 'scripts', 'styleguide', cb);
});