forked from h3llrais3r/Auto-Subliminal
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
174 lines (152 loc) · 5.17 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
167
168
169
170
171
172
173
174
var gulp = require('gulp');
var gulp_clean_css = require('gulp-clean-css');
var gulp_concat = require('gulp-concat');
var gulp_copy = require('gulp-copy');
var gulp_rename = require('gulp-rename');
var gulp_uglify = require('gulp-uglify');
var gulp_util = require('gulp-util');
var del = require('del');
/*************
Configuration
*************/
var vendor = {
// ATTENTION: please keep files in correct order (f.e. bootstrap needs jquery so jquery must be loaded before!)
js: [
// jquery
'node_modules/jquery/dist/jquery.js',
// jquery countdown
'node_modules/jquery-countdown/dist/jquery.countdown.js',
// jquery hoverintent
'node_modules/jquery-hoverintent/jquery.hoverIntent.js',
// tablesorter
'node_modules/tablesorter/dist/js/jquery.tablesorter.js',
'node_modules/tablesorter/dist/js/jquery.tablesorter.widgets.js',
'node_modules/tablesorter/dist/js/extras/jquery.tablesorter.pager.min.js',
'node_modules/tablesorter/dist/js/widgets/widget-reflow.min.js',
// pnotify
'node_modules/pnotify/src/pnotify.js',
'node_modules/pnotify/src/pnotify.buttons.js',
'node_modules/pnotify/src/pnotify.desktop.js',
// bootstrap
'node_modules/bootstrap/dist/js/bootstrap.js',
// bootstrap hover dropdown
'node_modules/bootstrap-hover-dropdown/bootstrap-hover-dropdown.js',
// bootstrap toggle
'node_modules/bootstrap-toggle/js/bootstrap-toggle.js'
],
// ATTENTION: please keep files in correct order (f.e. bootstrap is default style so it must be loaded first!)
css: [
// bootstrap
'node_modules/bootstrap/dist/css/bootstrap.css',
'node_modules/bootstrap/dist/css/bootstrap-theme.css',
// bootstrap toggle
'node_modules/bootstrap-toggle/css/bootstrap-toggle.css',
// tablesorter
'node_modules/tablesorter/dist/css/jquery.tablesorter.pager.min.css',
// pnotify
'node_modules/pnotify/src/pnotify.brighttheme.css',
'node_modules/pnotify/src/pnotify.buttons.css',
'node_modules/pnotify/src/pnotify.css',
// font awesome
'node_modules/font-awesome/css/font-awesome.css'
],
// if the folders must be in specific subfolder, adapt copy:vendor_images task!
images: [
// tablesorter
'node_modules/tablesorter/dist/css/images/**/*'
],
fonts: [
// bootstrap
'node_modules/bootstrap/dist/fonts/**/*',
// font awesome
'node_modules/font-awesome/fonts/**/*'
]
};
/************
Bundle tasks
************/
gulp.task('bundle:vendor_js', function () {
gulp_util.log('Bundle vendor js:');
gulp_util.log(vendor.js);
return gulp.src(vendor.js)
.pipe(gulp_concat('vendor.js'))
.pipe(gulp.dest('dist'));
});
gulp.task('bundle:vendor_css', function () {
gulp_util.log('Bundle vendor css:');
gulp_util.log(vendor.css);
return gulp.src(vendor.css)
.pipe(gulp_concat('vendor.css'))
.pipe(gulp.dest('dist'));
});
/************
Minify tasks
************/
gulp.task('minify:vendor_js', ['bundle:vendor_js'], function () {
return gulp.src('dist/vendor.js')
.pipe(gulp_rename('vendor.min.js'))
.pipe(gulp_uglify())
.pipe(gulp.dest('dist'));
});
gulp.task('minify:vendor_css', ['bundle:vendor_css'], function () {
return gulp.src('dist/vendor.css')
.pipe(gulp_rename('vendor.min.css'))
.pipe(gulp_clean_css())
.pipe(gulp.dest('dist'));
});
/**********
Clean task
**********/
var cleanup_sources = [
'dist',
'web/static/js/vendor.js',
'web/static/js/vendor.min.js',
'web/static/css/vendor.css',
'web/static/css/vendor.min.css',
'web/static/images/vendor',
'web/static/fonts'
];
gulp.task('clean', function () {
gulp_util.log('Clean files/folders:');
gulp_util.log(cleanup_sources);
return del.sync(cleanup_sources);
});
/**********
Copy tasks
**********/
gulp.task('copy:vendor_js', ['minify:vendor_js'], function () {
return gulp.src(['dist/vendor.js', 'dist/vendor.min.js'])
.pipe(gulp.dest('web/static/js'));
});
gulp.task('copy:vendor_css', ['minify:vendor_css'], function () {
return gulp.src(['dist/vendor.css', 'dist/vendor.min.css'])
.pipe(gulp.dest('web/static/css'));
});
gulp.task('copy:vendor_images', function () {
return gulp.src(vendor.images)
.pipe(gulp.dest(function (path) {
//gulp_util.log(JSON.stringify(path));
// copy images in specific subfolder
if (path.base.indexOf('tablesorter') != -1) {
return 'web/static/images/vendor/tablesorter';
} else {
return 'web/static/images/vendor';
}
}));
});
gulp.task('copy:vendor_fonts', function () {
return gulp.src(vendor.fonts)
.pipe(gulp.dest('web/static/fonts'));
});
/************
Install task
************/
gulp.task('install', ['copy:vendor_js', 'copy:vendor_css', 'copy:vendor_images', 'copy:vendor_fonts']);
/**********
Build task
**********/
gulp.task('build', ['clean', 'install']);
/************
Default task
************/
gulp.task('default', ['build']);