forked from lichess-org/lila
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
55 lines (49 loc) · 1.26 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
var gulp = require('gulp');
var svgmin = require('gulp-svgmin');
var map = require('map-stream');
var sourceDir = 'public/piece-src/';
var destDir = 'public/stylesheets/piece/';
var pieces = [].concat.apply([], ['w', 'b'].map(function(color) {
return ['P', 'B', 'N', 'R', 'Q', 'K'].map(function(role) {
return color + role;
});
}));
function makeCss(code) {
console.log(code);
return code;
}
var log = function(file, cb) {
console.log(file.path);
console.log(file.contents);
console.log(cb);
// cb(null, file);
};
gulp.task('piece-sprite', function() {
['cburnett', 'alpha'].forEach(function(theme) {
gulp.src(sourceDir + theme + '/*.svg')
.pipe(svgmin({
multipass: true
}))
.pipe(map(log));
});
});
gulp.task('piece-sprite-fs', function() {
var svgo = new SVGOptim({
multipass: true
});
var svgs = {};
['cburnett', 'alpha'].forEach(function(theme) {
svgs[theme] = {};
pieces.map(function(piece) {
var file = new File({
base: sourceDir + theme + '/' + piece + '.svg'
});
console.log(file.relative);
console.log(file.contents);
svgo.optimize(String(file.contents), function(result) {
svgs[theme][piece] = result.data;
});
});
});
console.log(svgs);
});