forked from positive-js/mosaic-icons
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGruntfile.js
145 lines (135 loc) · 6.66 KB
/
Gruntfile.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
const PATH_BUILD_ICONS = './build/icons',
PATH_DIST_FONTS = './dist/fonts',
PATH_DIST_STYLES = './dist/styles',
PATH_DIST_HTML = './dist/html';
const SKETCH_FILE_DEF = 'mosaic-icons-iconset.sketch';
module.exports = function (grunt) {
let sketch_file = grunt.option('file');
if (sketch_file === undefined || sketch_file === true) {
sketch_file = SKETCH_FILE_DEF;
}
grunt.loadNpmTasks('grunt-shell');
grunt.initConfig({
sketch_export: {
run: {
options: {
type: 'slices',
scales: [1.0],
formats: ['svg']
},
src: sketch_file,
dest: PATH_BUILD_ICONS
}
},
webfont: {
run: {
src: PATH_BUILD_ICONS + '/*.svg',
dest: PATH_DIST_FONTS,
destCss: PATH_DIST_STYLES,
destScss: PATH_DIST_STYLES,
options: {
relativeFontPath: PATH_DIST_FONTS,
stylesheets: ['less', 'scss', 'css'],
htmlDemo: true,
destHtml: PATH_DIST_HTML,
template: 'template.css',
fontFamilyName: 'PT Mosaic Icons',
font: 'Mosaic',
version: '2.8.1',
types: 'woff,ttf',
/*
Для тестовой генерации шрифта под Windows нужно раскомментировать эти строки.
Шрифт в этом случае генерируется криво, не используйте это для публикации пакета!!!
*/
// engine: 'node',
// autoHint: false,
codepoints: {
'angle-down-L_16' : 0xF101,
'angle-down-M_16' : 0xF102,
'angle-down-S_16' : 0xF103,
'calendar_16' : 0xF104,
'check_16' : 0xF105,
'circle-8_16' : 0xF106,
'clock_16' : 0xF107,
'close-L_16' : 0xF108,
'close-M_16' : 0xF109,
'close-S_16' : 0xF10A,
'ellipsis_16' : 0xF10B,
'folder-closed_16' : 0xF10C,
'folder-opened_16' : 0xF10D,
'gear_16' : 0xF10E,
'hamburger_16' : 0xF10F,
'pause_16' : 0xF110,
'play_16' : 0xF111,
'stop_16' : 0xF112,
'triangle-down_16' : 0xF113,
'upload-to-cloud_24' : 0xF114,
'upload-to-cloud_64' : 0xF115,
'error_16' : 0xF116,
'info_16' : 0xF117,
'search_16' : 0xF118,
'download_16' : 0xF119,
'copy_16' : 0xF11A,
'minus_16' : 0xF11B,
'angle-up-L_16' : 0xF11C,
'angle-up-M_16' : 0xF11D,
'angle-up-S_16' : 0xF11E,
'angle-left-L_16' : 0xF11F,
'angle-left-M_16' : 0xF120,
'angle-left-S_16' : 0xF121,
'angle-right-L_16' : 0xF122,
'angle-right-M_16' : 0xF123,
'angle-right-S_16' : 0xF124,
'bell_32' : 0xF125,
'hamburger_32' : 0xF126,
'close-L_32' : 0xF127,
'angle-right-M_32' : 0xF128,
'triangle-up_16' : 0xF129,
},
startCodepoint: 0xF701
}
}
},
shell: {
publish: {command: 'npm publish'},
svgrename: {
command: 'cd build/icons && for f in *.svg; do mv "$f" "${f#mc-}"; done'
}
},
rename: {
main: {
files: [
{src: [PATH_DIST_FONTS + '/' + 'mosaic.ttf'], dest: PATH_DIST_FONTS + '/' + 'mc-icons.ttf'},
{src: [PATH_DIST_FONTS + '/' + 'mosaic.woff'], dest: PATH_DIST_FONTS + '/' + 'mc-icons.woff'},
{src: [PATH_DIST_HTML + '/' + 'mosaic.html'], dest: PATH_DIST_HTML + '/' + 'mc-icons.html'},
{src: [PATH_DIST_STYLES + '/' + 'mosaic.less'], dest: PATH_DIST_STYLES + '/' + 'mc-icons.less'},
{src: [PATH_DIST_STYLES + '/' + '_Mosaic.scss'], dest: PATH_DIST_STYLES + '/' + '_mc-icons.scss'},
{src: [PATH_DIST_STYLES + '/' + 'Mosaic.css'], dest: PATH_DIST_STYLES + '/' + 'mc-icons.css'}
]
}
},
replace: {
remove_mask: {
src: [PATH_BUILD_ICONS + '/*.svg'],
overwrite: true, // overwrite matched source files
replacements: [
{from: / fill="(.*?)"/m, to: ''},
{from: /(\s*)<\/defs[\s\S]*<\/g>/m, to: ''},
{from: /(\s*)<defs>/m, to: ''},
{from: / id="(.*?)"/m, to: ''},
{from: /xmlns:xlink="(.*?)"/m, to: ''},
{from: /(\s*)<g[\s\S]*?>/m, to: ''},
{from: /(\s*)<\/g>/m, to: ''},
{from: /<svg/m, to: '<svg fill="#000"'},
{from: / transform="(.*?)"/m, to: ''},
{from: / fill-rule="(.*?)"/m, to: ''},]
}
}
});
grunt.loadNpmTasks('grunt-sketch');
grunt.loadNpmTasks('grunt-webfont');
grunt.loadNpmTasks('grunt-rename-util');
grunt.loadNpmTasks('grunt-text-replace');
grunt.registerTask('publish', ['sketch_export:run', 'shell:svgrename', 'replace:remove_mask', 'webfont:run', 'rename:main', 'shell:publish']);
grunt.registerTask('default', ['sketch_export:run', 'shell:svgrename', 'replace:remove_mask', 'webfont:run', 'rename:main',]);
};