svgo plugin for setting up specified attributes (ex stroke and fill) with currentColor value
install via npm
npm install @uranetz/setcurrentcolor
from this version and up property to be replaced could be in style attribute too
add plugin to svgo optimize:
import setCurrentColor from '@uranetz/setcurrentcolor';
optimize( data, {
//all other staff here
plugins: [
setCurrentColor
],
});
The "attrs" parameter a pattern to set currentColor value - default to fill and stroke
The "force" parameter - changes attrs if they alredy set - default is false.
The "path" parameter a pattern to set currentColor for
For test run
npm test
Simple example showed in test.js. Advanced usage can be found in index.js .