forked from mdehoog/Semantic-UI-Calendar
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
108 lines (99 loc) · 2.71 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
var gulp = require('gulp');
var less = require('gulp-less');
var autoprefixer = require('gulp-autoprefixer');
var flatten = require('gulp-flatten');
var clone = require('gulp-clone');
var replace = require('gulp-replace');
var minifyCSS = require('gulp-clean-css');
var rename = require('gulp-rename');
var uglify = require('gulp-uglify');
var path = require('path');
var npmPackage = require('./package.json');
var settings = {
less: {
paths: [
path.join(__dirname, 'node_modules', 'semantic-ui-less')
]
},
/* What Browsers to Prefix */
prefix: {
browsers: [
'last 2 versions',
'> 1%',
'opera 12.1',
'bb 10',
'android 4'
]
},
/* File Renames */
rename: {
minJS : { extname : '.min.js' },
minCSS : { extname : '.min.css' },
rtlCSS : { extname : '.rtl.css' },
rtlMinCSS : { extname : '.rtl.min.css' }
},
/* Minified CSS Concat */
minify: {
processImport : false,
restructuring : false,
keepSpecialComments : 1,
roundingPrecision : -1,
},
/* Minified JS Settings */
uglify: {
mangle : true,
preserveComments : 'some'
}
};
var comments = {
// remove all comments from config files (.variable)
variables : {
in : /(\/\*[\s\S]+?\*\/+)[\s\S]+?\/\* End Config \*\//,
out : '$1',
},
// add version to first comment
license: {
in : /(^\/\*[\s\S]+)(# Semantic UI )([\s\S]+?\*\/)/,
out : '$1$2' + npmPackage.version + ' $3'
},
// adds uniform spacing around comments
large: {
in : /(\/\*\*\*\*[\s\S]+?\*\/)/mg,
out : '\n\n$1\n'
},
small: {
in : /(\/\*---[\s\S]+?\*\/)/mg,
out : '\n$1\n'
},
tiny: {
in : /(\/\* [\s\S]+? \*\/)/mg,
out : '\n$1'
}
};
gulp.task('default', function() {
gulp.start('less', 'javascript');
});
gulp.task('less', function () {
return gulp.src('./src/definitions/**/*.less')
.pipe(less(settings.less))
.pipe(autoprefixer(settings.prefix))
.pipe(replace(comments.variables.in, comments.variables.out))
.pipe(replace(comments.license.in, comments.license.out))
.pipe(replace(comments.large.in, comments.large.out))
.pipe(replace(comments.small.in, comments.small.out))
.pipe(replace(comments.tiny.in, comments.tiny.out))
.pipe(flatten())
.pipe(gulp.dest('./dist'))
.pipe(minifyCSS(settings.minify))
.pipe(rename(settings.rename.minCSS))
.pipe(gulp.dest('./dist'));
});
gulp.task('javascript', function () {
return gulp.src('./src/definitions/**/*.js')
.pipe(flatten())
.pipe(replace(comments.license.in, comments.license.out))
.pipe(gulp.dest('./dist'))
.pipe(uglify(settings.uglify))
.pipe(rename(settings.rename.minJS))
.pipe(gulp.dest('./dist'));
});