-
Notifications
You must be signed in to change notification settings - Fork 17
/
gulpfile.js
246 lines (216 loc) · 6.64 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
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
var _ = require('lodash');
var clean = require('gulp-clean');
var colors = require('./src/colors');
var compass = require('gulp-compass')
var gulp = require('gulp');
var header = require('gulp-header');
var less = require('gulp-less');
var path = require('path');
var packageConfig = require('./package.json');
var rename = require('gulp-rename');
var sass = require('gulp-ruby-sass');
var stylus = require('gulp-stylus');
var sync = require('gulp-config-sync');
var template = require('gulp-template');
var util = require('util');
var paths = {
destination: 'dist',
test: 'test',
stylus: 'palette.styl',
sass: 'palette.scss',
less: 'palette.less',
css: 'palette.css',
cssVar: 'palette.var.css',
js: 'palette.js',
};
var banner = '' +
'/**\n' +
' * <%= name %> v<%= version %>\n' +
' * <%= homepage %>\n' +
' */\n';
/**
* Generates all the plugins
*/
gulp.task('default', [/*'sync', */'clean-dist', 'stylus', 'sass', 'less', 'css', 'css-var', 'js']);
/**
* Generates the test files: compile lib to css
*/
gulp.task('test', ['clean-test', 'test-page', 'test-stylus', 'test-sass', 'test-less', 'css', 'css-var', 'js']);
////////////////////////////////////////////////////////////////////////////////
// CSS
////////////////////////////////////////////////////////////////////////////////
/**
* Generates the css files
*/
gulp.task('css', ['clean-dist', 'clean-test'], function() {
return gulp.src('src/templates/css')
.pipe(template({ colors: colors, }))
.pipe(rename(paths.css))
.pipe(header(banner, packageConfig))
.pipe(gulp.dest(paths.destination));
});
/**
* Generates the css-var files
*/
gulp.task('css-var', ['clean-dist', 'clean-test'], function() {
return gulp.src('src/templates/css-var')
.pipe(template({ colors: colors, }))
.pipe(rename(paths.cssVar))
.pipe(header(banner, packageConfig))
.pipe(gulp.dest(paths.destination));
});
////////////////////////////////////////////////////////////////////////////////
// JSON
////////////////////////////////////////////////////////////////////////////////
/**
* Generates the js files
*/
gulp.task('js', ['clean-dist', 'clean-test'], function() {
return gulp.src('src/templates/js')
.pipe(template({ colors: colors, }))
.pipe(rename(paths.js))
.pipe(header(banner, packageConfig))
.pipe(gulp.dest(paths.destination));
});
////////////////////////////////////////////////////////////////////////////////
// STYLUS
////////////////////////////////////////////////////////////////////////////////
/**
* Generates the stylus files
*/
gulp.task('stylus', ['clean-dist', 'clean-test'], function() {
return gulp.src('src/templates/stylus')
.pipe(template({ colors: colors, }))
.pipe(rename(paths.stylus))
.pipe(header(banner, packageConfig))
.pipe(gulp.dest(paths.destination));
});
/**
* Stylus css for test
*/
gulp.task('test-stylus', ['stylus'], function() {
gulp.src('src/templates/test-stylus')
.pipe(template({
path: path.join('../../', paths.destination, paths.stylus),
colors: colors,
}))
.pipe(stylus())
.pipe(rename('stylus.css'))
.pipe(gulp.dest(paths.test));
});
////////////////////////////////////////////////////////////////////////////////
// SASS
////////////////////////////////////////////////////////////////////////////////
/**
* Generates the sass files
*/
gulp.task('sass', ['clean-dist', 'clean-test'], function() {
return gulp.src('src/templates/scss')
.pipe(template({ colors: colors, }))
.pipe(rename(paths.sass))
.pipe(header(banner, packageConfig))
.pipe(gulp.dest(paths.destination));
});
/**
* Sass css for test
*/
gulp.task('test-sass', ['sass', 'test-sass-template'], function() {
gulp.src(path.join(paths.test, '*.scss'))
.pipe(compass({
css: paths.test,
sass: paths.test,
import_path: paths.destination,
}))
.pipe(gulp.dest(paths.test));
})
gulp.task('test-sass-template', function() {
return gulp.src('src/templates/test-scss')
.pipe(template({
path: paths.sass,
colors: colors,
}))
.pipe(rename('sass.scss'))
.pipe(gulp.dest(paths.test));
});
////////////////////////////////////////////////////////////////////////////////
// LESS
////////////////////////////////////////////////////////////////////////////////
/**
* Generates the less files
*/
gulp.task('less', ['clean-dist', 'clean-test'], function() {
return gulp.src('src/templates/less')
.pipe(template({ colors: colors, }))
.pipe(rename(paths.less))
.pipe(header(banner, packageConfig))
.pipe(gulp.dest(paths.destination));
});
gulp.task('test-less', ['less', 'test-less-template'], function () {
gulp.src(path.join(paths.test, '*.less'))
.pipe(less({
paths: [ path.join(__dirname, paths.destination) ],
}))
.pipe(rename('less.css'))
.pipe(gulp.dest(paths.test));
});
gulp.task('test-less-template', function() {
return gulp.src('src/templates/test-less')
.pipe(template({
path: path.join('../', paths.destination, paths.less),
colors: colors,
}))
.pipe(rename('less.less'))
.pipe(gulp.dest(paths.test));
});
////////////////////////////////////////////////////////////////////////////////
// TESTS
////////////////////////////////////////////////////////////////////////////////
/**
* Test page html
*/
gulp.task('test-page', ['clean-dist', 'clean-test'], function() {
gulp.src('src/templates/test-page')
.pipe(template({
path: {
css: path.join('../', paths.destination, paths.css),
js: path.join('../', paths.destination, paths.js),
},
colors: colors,
}))
.pipe(rename('index.html'))
.pipe(gulp.dest(paths.test));
});
////////////////////////////////////////////////////////////////////////////////
// CLEAN
////////////////////////////////////////////////////////////////////////////////
/**
* Cleans the distribution folder
*/
gulp.task('clean-dist', function() {
return gulp.src(paths.destination, {read: false})
.pipe(clean());
});
/**
* Cleans the test
*/
gulp.task('clean-test', function() {
return gulp.src(paths.test, {read: false})
.pipe(clean());
});
////////////////////////////////////////////////////////////////////////////////
// VERSIONING
////////////////////////////////////////////////////////////////////////////////
gulp.task('sync', function() {
return gulp.src('bower.json')
.pipe(sync())
.pipe(gulp.dest('.'));
});
////////////////////////////////////////////////////////////////////////////////
// CLEAN
////////////////////////////////////////////////////////////////////////////////
/**
* Watch dev
*/
gulp.task('watch', ['default', 'test'], function () {
gulp.watch('src/templates/*', ['default', 'test']);
});