Created
June 22, 2016 15:41
-
-
Save icidasset/67902f8d9d967586946c07b7593dc6c7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const iconPlugin = { | |
iconPlugin: { | |
type: 'perItem', | |
fn: item => { | |
if (item.elem) { | |
item.eachAttr(attr => { | |
if ([ 'fill', 'stroke' ].indexOf(attr.name) > -1) { | |
// if (attr.value === '#000') { | |
// attr.value = 'currentColor'; | |
// } else if (attr.value === '#F00') { | |
// item.removeAttr(attr.name); | |
// } | |
attr.value = 'currentColor'; | |
} | |
}); | |
var hasStroke = item.computedAttr('stroke'); | |
var miterLimit = item.computedAttr('stroke-miterlimit'); | |
var lineJoinIsMiter = [ 'bevel', 'round' ] | |
.indexOf(item.computedAttr('stroke-linejoin')) === -1; | |
if (hasStroke && !miterLimit && lineJoinIsMiter) { | |
item.addAttr({ | |
name: 'stroke-miterlimit', | |
value: '5', | |
prefix: '', | |
local: 'stroke-miterlimit', | |
}); | |
} | |
} | |
}, | |
}, | |
}; | |
const svgoConfig = { | |
plugins: [ | |
iconPlugin, | |
{ removeDimensions: true }, | |
{ removeTitle: true }, | |
{ removeUselessDefs: false }, | |
{ removeAttrs: { | |
attrs: ['stroke-width'], | |
}}, | |
], | |
}; | |
export default { | |
shape: { | |
align: { '*': { '%s': .5 }}, | |
transform: [{ svgo: svgoConfig }], | |
}, | |
mode: { symbol: { | |
dest: '.', | |
sprite: 'sprite.svg', | |
}}, | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment