All elements targeted by the selectors specified in the configuration will get new attribute(s) or update existing attribute(s).
The resulting file will be moved to [path/to/destination] leaving the original file intact in [path/to/source/files].
The module returns a Promise.
{
".class1": {
"fill": "#FFFF00"
},
".class2": {
"fill": "#FFCC00"
},
"#id": {
"fill": "#CC22CC"
}
}
$ svgtemplates path/to/svg/files path/to/destination path/to/config/file
test.js
var svgtemplates = require('svg-templates');
svgtemplates({
source: 'path/to/svg/files',
dest: 'path/to/destination',
config: {
".class1": {
"fill": "#00FF00"
},
".class2": {
"fill": "#FFCC00"
},
"#id": {
"fill": "#CC22CC"
}
}
});
$ node test.js
gulpfile.js
var gulp = require('gulp');
var svgtemplates = require( 'svg-templates' );
var svgOptions = {
source: 'source/img/svgs',
dest: 'dist/img/svg',
config: {
".class1": {
"fill": "#FFFF00"
},
".class2": {
"fill": "#FFCC00"
},
"#id": {
"fill": "#CC22CC"
}
}
};
gulp.task('default', svgtemplates( svgOptions ) );
$ gulp