-
Notifications
You must be signed in to change notification settings - Fork 1
/
gulpfile.js
62 lines (58 loc) · 1.42 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
const gulp = require('gulp');
const replace = require('gulp-replace');
const merge = require('merge-stream');
const _ = require('lodash');
const svgSprite = require('gulp-svg-sprite');
const ICON_CATEGORIES = [
'action',
'alert',
'av',
'communication',
'content',
'device',
'editor',
'file',
'hardware',
'image',
'maps',
'navigation',
'notification',
'places',
'social',
'toggle',
];
gulp.task('svg-sprites', () =>
_(ICON_CATEGORIES)
.map((category) =>
gulp.src([`./node_modules/material-design-icons/${category}/svg/production/*_24px.svg`])
.pipe(svgSprite(getSvgSpriteConfig(category))))
.thru(merge)
.value()
.pipe(replace(/id=\"ic_([0-9a-zA-z_]+)_24px\"/g, function (pattern, replacement) {
var out = replacement.replace(/_/g, '-');
return 'id="' + out + '"';
}))
.pipe(gulp.dest('./dist')));
gulp.task('copy-package', () => {
return gulp.src([
'package.json'
])
.pipe(gulp.dest('dist'));
})
function getSvgSpriteConfig(category) {
return {
shape: {
dimension: {
maxWidth: 24,
maxHeight: 24
},
},
mode: {
css: {
bust: false,
dest: './',
sprite: `./svg-sprite-${category}.svg`,
},
}
};
}