forked from getredash/redash
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
131 lines (109 loc) · 3.36 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
// Generated on 2016-02-09 using generator-angular 0.15.1
'use strict';
var gulp = require('gulp');
var $ = require('gulp-load-plugins')();
var lazypipe = require('lazypipe');
var rimraf = require('rimraf');
var wiredep = require('wiredep').stream;
var runSequence = require('run-sequence');
var map = require('lodash.map');
var yeoman = {
app: 'rd_ui/app',
dist: 'rd_ui/dist'
};
function applyAppPath(p) {
if (typeof p === 'string') {
return yeoman.app + p;
} else {
return map(p, function (path) {
return applyAppPath(path);
});
}
}
var paths = {
scripts: [yeoman.app + '/scripts/**/*.js'],
styles: [yeoman.app + '/styles/**/*.css'],
views: {
main: applyAppPath(['/index.html', '/vendor_scripts.html', '/login.html', '/embed.html', '/public.html', '/app_layout.html', '/signed_out_layout.html']),
files: [yeoman.app + '/views/**/*.html']
}
};
////////////////////////
// Reusable pipelines //
////////////////////////
var lintScripts = lazypipe()
.pipe($.jshint, '.jshintrc')
.pipe($.jshint.reporter, 'jshint-stylish');
var styles = lazypipe()
.pipe($.autoprefixer, 'last 1 version')
.pipe(gulp.dest, '.tmp/styles');
///////////
// Tasks //
///////////
gulp.task('styles', function () {
return gulp.src(paths.styles)
.pipe(styles());
});
gulp.task('lint:scripts', function () {
return gulp.src(paths.scripts)
.pipe(lintScripts());
});
gulp.task('clean:tmp', function (cb) {
rimraf('./.tmp', cb);
});
// inject bower components
gulp.task('bower', function () {
return gulp.src(paths.views.main)
.pipe(wiredep({
directory: yeoman.app + '/bower_components',
ignorePath: '..'
}))
.pipe(gulp.dest(yeoman.app + '/views'));
});
///////////
// Build //
///////////
gulp.task('clean:dist', function (cb) {
rimraf('./dist', cb);
});
gulp.task('client:build', ['html', 'styles'], function () {
var jsFilter = $.filter('**/*.js');
var cssFilter = $.filter('**/*.css');
return gulp.src(paths.views.main)
.pipe($.useref({searchPath: [yeoman.app, '.tmp']}))
.pipe(jsFilter)
.pipe($.ngAnnotate())
.pipe($.uglify())
.pipe(jsFilter.restore())
.pipe($.print())
.pipe(cssFilter)
.pipe($.minifyCss({cache: true}))
.pipe(cssFilter.restore())
.pipe(new $.revAll({dontRenameFile: ['.html'], dontUpdateReference: ['vendor_scripts.html', 'app_layout.html', 'signed_out_layout.html']}).revision())
.pipe(gulp.dest(yeoman.dist));
});
gulp.task('html', function () {
return gulp.src(yeoman.app + '/views/**/*')
.pipe(gulp.dest(yeoman.dist + '/views'));
});
gulp.task('images', function () {
return gulp.src(yeoman.app + '/images/**/*')
.pipe($.cache($.imagemin({
optimizationLevel: 5,
progressive: true,
interlaced: true
})))
.pipe(gulp.dest(yeoman.dist + '/images'));
});
gulp.task('copy:extras', function () {
return gulp.src(applyAppPath(['/*/.*', '/google_login.png', '/favicon.ico', '/robots.txt']), { dot: true })
.pipe(gulp.dest(yeoman.dist));
});
gulp.task('copy:fonts', function () {
return gulp.src(applyAppPath(['/fonts/**/*', '/bower_components/font-awesome/fonts/*', '/bower_components/material-design-iconic-font/dist/fonts/*']))
.pipe(gulp.dest(yeoman.dist + '/fonts'));
});
gulp.task('build', ['clean:dist'], function () {
runSequence(['images', 'copy:extras', 'copy:fonts', 'client:build']);
});
gulp.task('default', ['build']);