forked from aparsons/bag-of-holding
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
164 lines (126 loc) · 4.25 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
var gulp = require('gulp');
var addsrc = require('gulp-add-src');
var concat = require('gulp-concat');
var minifyCSS = require('gulp-minify-css');
var rename = require('gulp-rename');
var sass = require('gulp-sass');
var uglify = require('gulp-uglify');
var paths = {
'bower': 'bower_components',
'assets': 'assets',
'dist': 'project/boh/static/boh',
'templates': {
'reports': 'project/boh/templates/boh/reports'
}
};
var minify = true;
gulp.task('styles', function() {
var styles = gulp.src([
paths.assets + '/styles/application.scss'
])
.pipe(sass({
includePaths: [
paths.bower + '/bootstrap-sass/assets/stylesheets',
paths.bower + '/fontawesome/scss'
]
}))
.pipe(addsrc(paths.bower + '/bootstrap-markdown/css/bootstrap-markdown.min.css'))
.pipe(addsrc(paths.bower + '/select2/select2.css'))
//.pipe(addsrc(paths.bower + '/select2/select2-bootstrap.css'))
.pipe(addsrc(paths.bower + '/select2-bootstrap-css/select2-bootstrap.css'))
.pipe(concat('application.min.css'));
if (minify)
styles.pipe(minifyCSS({
keepSpecialComments: 0
}));
styles.pipe(gulp.dest(paths.dist + '/css'));
});
// Styles for Reports
gulp.task('report-styles', function() {
var styles = gulp.src([
paths.assets + '/styles/reports.scss'
])
.pipe(sass({
includePaths: [
paths.bower + '/bootstrap-sass/assets/stylesheets',
paths.bower + '/fontawesome/scss'
]
}))
.pipe(rename('base.css'));
if (minify)
styles.pipe(minifyCSS({
keepSpecialComments: 0
}));
styles.pipe(gulp.dest(paths.templates.reports));
});
gulp.task('scripts', function() {
// JQuery + Bootstrap + Application
var scripts = gulp.src([
paths.bower + '/jquery/dist/jquery.js',
paths.bower + '/bootstrap-sass/assets/javascripts/bootstrap.js',
paths.bower + '/markdown/lib/markdown.js',
paths.bower + '/bootstrap-markdown/js/bootstrap-markdown.js',
paths.bower + '/select2/select2.js',
paths.assets + '/scripts/application.js'
])
.pipe(concat('application.min.js'));
if (minify)
scripts.pipe(uglify());
scripts.pipe(gulp.dest(paths.dist + '/js'));
// Modernizr
var modernizr = gulp.src([
paths.bower + '/modernizer/modernizr.js'
])
.pipe(rename('modernizr.min.js'));
if (minify)
modernizr.pipe(uglify());
modernizr.pipe(gulp.dest(paths.dist + '/js'));
});
gulp.task('fonts', function() {
// Bootstrap Glyphicons
gulp.src(paths.bower + '/bootstrap-sass/assets/fonts/**/*')
.pipe(gulp.dest(paths.dist + '/fonts'));
// Font Awesome
gulp.src(paths.bower + '/fontawesome/fonts/*')
.pipe(gulp.dest(paths.dist + '/fonts/fontawesome'));
// Select 2
gulp.src([
paths.bower + '/select2/select2.png',
paths.bower + '/select2/select2-spinner.gif'
]).pipe(gulp.dest(paths.dist + '/css'))
});
gulp.task('vendor', function() {
// Bootstrap Datepicker CSS
var datepicker_css = gulp.src(paths.bower + '/bootstrap-datepicker/dist/css/bootstrap-datepicker3.css')
.pipe(rename('datepicker.min.css'));
if (minify)
datepicker_css.pipe(minifyCSS({
keepSpecialComments: 0
}));
datepicker_css.pipe(gulp.dest(paths.dist + '/css'));
// Bootstrap Datepicker JS
var datepicker_js = gulp.src(paths.bower + '/bootstrap-datepicker/dist/js/bootstrap-datepicker.js')
.pipe(rename('datepicker.min.js'));
if (minify)
datepicker_js.pipe(uglify());
datepicker_js.pipe(gulp.dest(paths.dist + '/js'));
// Chart.js
var chart_js = gulp.src(paths.bower + '/Chart.js/Chart.js')
.pipe(rename('chart.min.js'));
if (minify)
chart_js.pipe(uglify());
chart_js.pipe(gulp.dest(paths.dist + '/js'));
});
gulp.task('default', ['styles', 'report-styles', 'scripts', 'fonts', 'vendor']);
gulp.task('development', function() {
minify = false;
gulp.start('default');
});
gulp.task('watch', ['default'], function() {
gulp.watch(paths.assets + '/styles/**/*.scss', ['styles', 'report-styles']);
gulp.watch(paths.assets + '/scripts/**/*.js', ['scripts']);
});
gulp.task('watch-development', ['development'], function() {
gulp.watch(paths.assets + '/styles/**/*.scss', ['styles', 'report-styles']);
gulp.watch(paths.assets + '/scripts/**/*.js', ['scripts']);
});