Answer the question
In order to leave comments, you need to log in
How to create a rule for Gulp task?
There is a task for assembling SVG
gulp.task('svg', function () {
var svgSrc = gulp.src(['app/img/svg/**.*','!app/img/svg/defs.svg','!app/img/svg/sprite.svg']);
svgSrc
.pipe(svgmin({
js2svg: {
pretty: true
}
}))
.pipe(cheerio({
run: function ($) {
$('[fill]').removeAttr('fill'); //remove if need color icon
$('[style]').removeAttr('style');
},
parserOptions: {xmlMode: true }
}))
.pipe(svgSprite( {
mode:{
symbol: true,
}
}))
.pipe(rename("pack.html"))
.pipe(gulp.dest('app/img/'))
.pipe(gulp.dest('dist/img/'))
svgSrc
.pipe(svgSpriteTempl())
.pipe(gulp.dest('app/img/'))
.pipe(gulp.dest('dist/img/'))
var svgArray =[];
fs.writeFile("app/html/block_html/_svg.pug",'');
fs.readdirSync('app/img/svg').forEach(file => {
svgArray.push("\'"+file+"\'");
})
fs.writeFile("app/html/block_html/_svg.pug",'- svgArray = ['+ svgArray+'];');
});
.pipe(cheerio({
run: function ($) {
$('[fill]').removeAttr('fill'); //remove if need color icon
$('[style]').removeAttr('style');
},
parserOptions: {xmlMode: true }
}))
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question