build.js
3.8 KB
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
/*******************************
Build Task
*******************************/
var
gulp = require('gulp'),
// node dependencies
fs = require('fs'),
// gulp dependencies
autoprefixer = require('gulp-autoprefixer'),
chmod = require('gulp-chmod'),
clone = require('gulp-clone'),
flatten = require('gulp-flatten'),
gulpif = require('gulp-if'),
less = require('gulp-less'),
minifyCSS = require('gulp-clean-css'),
plumber = require('gulp-plumber'),
print = require('gulp-print'),
rename = require('gulp-rename'),
replace = require('gulp-replace'),
rtlcss = require('gulp-rtlcss'),
uglify = require('gulp-uglify'),
// user config
config = require('../config/user'),
// install config
tasks = require('../config/tasks'),
install = require('../config/project/install'),
// shorthand
globs = config.globs,
assets = config.paths.assets,
output = config.paths.output,
source = config.paths.source,
banner = tasks.banner,
comments = tasks.regExp.comments,
log = tasks.log,
settings = tasks.settings
;
// add internal tasks (concat release)
require('../collections/internal')(gulp);
module.exports = function(callback) {
var
stream,
compressedStream,
uncompressedStream
;
console.info('Building Semantic');
if( !install.isSetup() ) {
console.error('Cannot build files. Run "gulp install" to set-up Semantic');
return;
}
// unified css stream
stream = gulp.src(source.definitions + '/**/' + globs.components + '.less')
.pipe(plumber())
.pipe(less(settings.less))
.pipe(autoprefixer(settings.prefix))
.pipe(rtlcss())
.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())
;
// two concurrent streams from same source to concat release
uncompressedStream = stream.pipe(clone());
compressedStream = stream.pipe(clone());
uncompressedStream
.pipe(plumber())
.pipe(replace(assets.source, assets.uncompressed))
.pipe(rename(settings.rename.rtlCSS))
.pipe(gulpif(config.hasPermission, chmod(config.permission)))
.pipe(gulp.dest(output.uncompressed))
.pipe(print(log.created))
.on('end', function() {
gulp.start('package uncompressed rtl css');
})
;
compressedStream = stream
.pipe(plumber())
.pipe(clone())
.pipe(replace(assets.source, assets.compressed))
.pipe(minifyCSS(settings.minify))
.pipe(rename(settings.rename.rtlMinCSS))
.pipe(gulpif(config.hasPermission, chmod(config.permission)))
.pipe(gulp.dest(output.compressed))
.pipe(print(log.created))
.on('end', function() {
callback();
gulp.start('package compressed rtl css');
})
;
// copy assets
gulp.src(source.themes + '/**/assets/**/' + globs.components + '?(s).*')
.pipe(gulpif(config.hasPermission, chmod(config.permission)))
.pipe(gulp.dest(output.themes))
;
// copy source javascript
gulp.src(source.definitions + '/**/' + globs.components + '.js')
.pipe(plumber())
.pipe(flatten())
.pipe(replace(comments.license.in, comments.license.out))
.pipe(gulpif(config.hasPermission, chmod(config.permission)))
.pipe(gulp.dest(output.uncompressed))
.pipe(print(log.created))
.pipe(uglify(settings.uglify))
.pipe(rename(settings.rename.minJS))
.pipe(gulp.dest(output.compressed))
.pipe(print(log.created))
.on('end', function() {
gulp.start('package compressed js');
gulp.start('package uncompressed js');
})
;
};