-
Notifications
You must be signed in to change notification settings - Fork 3
/
Gruntfile.js
112 lines (98 loc) · 2.18 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
module.exports = function(grunt) {
grunt.loadNpmTasks('grunt-svgmin');
grunt.loadNpmTasks('grunt-svgstore');
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-convert-svg-to-png');
grunt.loadNpmTasks('grunt-filenames-to-json');
// how to make svgs nice:
// optimize your svgs into a folder
// create an svg sprite
// if you really want to be fancy, xhr the sprite into the document to allow caching
// reference the node_modules package
// go through child folders
var SRC = 'node_modules/feather-icons/icons/',
SRC_REGEX = '**/*.svg';
var DIST = 'dist/',
DIST_OPTIMIZED = `${DIST}optimized/`,
DIST_PNG = `public/`,
DIST_SPRITE = `${DIST}sprite/`;
grunt.initConfig({
package: grunt.file.readJSON('package.json'),
//
// CLEAN
// removes all distrubtions prior to rebuilding
//
'clean': {
all: [
DIST_OPTIMIZED,
DIST_SPRITE,
],
},
//
// SVG optimization
// Gets rid of extra svg nonsense
// "flatten" puts everything from the folders into one folder
//
'svgmin': {
options: {
plugins: [
{ removeDesc: true },
{ removeViewbox: false },
{ mergePaths: false },
{ convertShapeToPath: false },
{ removeAttrs: {attrs: '(stroke)'} },
]
},
dist: {
files: [{
expand: true,
flatten: true,
cwd: SRC,
src: [SRC_REGEX],
dest: DIST_OPTIMIZED
}]
}
},
//
// SVG sprite
// For including in HTML
//
'svgstore': {
options: {
prefix: 'icon-'
},
default: {
files: [{
src: [`${DIST_OPTIMIZED}*.svg`],
dest: `${DIST_SPRITE}sprite.inc`
}]
}
},
'convert-svg-to-png': {
fallback: {
options: {
size: {w: 100, h: 100},
},
files: [{
flatten: true,
expand: true,
cwd: SRC,
src: [SRC_REGEX],
dest: DIST_PNG
}]
}
},
filenamesToJson : {
options : {
// true if full path should be included, default is false
fullPath : false,
// true if file extension should be included, default is false
extensions : false
},
// any valid glob
files : '**/js',
// path to write json to
destination : `${DIST}/output.json`
}
});
};