-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
94 lines (89 loc) · 2.5 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
'use strict';
var _ = require('lodash');
var glob = require('glob');
var gulp = require('gulp');
var concat_js = require('gulp-concat');
var concat_css = require('gulp-concat-css');
var merge = require('merge2');
var buffer = require('gulp-buffer');
var uglify = require('gulp-uglify');
var minify_css = require('gulp-cssnano');
function getGlobbedFiles(globPatterns) {
var urlRegex = new RegExp('^(?:[a-z]+:)?//', 'i');
var output = [];
if (_.isArray(globPatterns)) {
globPatterns.forEach(function(globPattern) {
output = _.union(output, getGlobbedFiles(globPattern));
});
} else if (_.isString(globPatterns)) {
if (urlRegex.test(globPatterns)) {
output.push(globPatterns);
} else {
var files = glob(globPatterns, {
sync: true
});
output = _.union(output, files);
}
}
return output;
}
var assets = {
css: [
'css/*.css'
],
js: [
'js/*.js'
]
};
gulp.task('js', function() {
merge.apply(this, [gulp.src(getGlobbedFiles(assets.js))])
.pipe(buffer())
.pipe(concat_js('bundle.min.js'))
.pipe(uglify({mangle: false}))
.pipe(gulp.dest('./bundle'));
});
gulp.task('css', function() {
merge.apply(this, [gulp.src(getGlobbedFiles(assets.css))])
.pipe(buffer())
.pipe(concat_css('bundle.css'))
.pipe(minify_css({
core: true,
minifySelectors: false,
autoprefixer: false,
calc: false,
colormin: false,
convertValues: false,
discardComments: true,
discardDuplicates: false,
discardEmpty: false,
discardOverridden: false,
discardUnused: false,
filterOptimiser: false,
filterPlugins: false,
functionOptimiser: false,
mergeIdents: false,
mergeLonghand: false,
mergeRules: false,
minifyFontValues: false,
minifyGradients: false,
minifyParams: false,
normalizeCharset: false,
normalizeUrl: false,
orderedValues: false,
reduceBackgroundRepeat: false,
reduceIdents: false,
reduceInitial: false,
reducePositions: false,
reduceTimingFunctions: false,
reduceTransforms: false,
styleCache: false,
svgo: false,
uniqueSelectors: false,
zindex: false
}))
.pipe(gulp.dest('./bundle'));
});
gulp.task('default', [
'js',
'css'
]);