Answer the question
In order to leave comments, you need to log in
How to prevent gulp task from executing with empty select?
In general, there is the following task for assembling an svg sprite (symbols)
import gulp from 'gulp';
import svgSymbols from 'gulp-svg-symbols';
import gulpIf from 'gulp-if';
import rename from 'gulp-rename';
import plumber from 'gulp-plumber';
import errorHandler from 'gulp-plumber-error-handler';
import path from 'path';
gulp.task('icons', () => (
gulp.src('app/icons/**/*.svg')
.pipe(plumber({errorHandler: errorHandler(`Error in 'icons' task`)}))
.pipe(svgSymbols({
templates: [
path.join(__dirname, '../tasks/icon-templates/svg-symbols.svg'),
path.join(__dirname, '../tasks/icon-templates/svg-symbols.scss')
],
transformData: (svg, defaultData) => {
return {
id: defaultData.id,
width: svg.width,
height: svg.height,
name: svg.name
};
}
}))
.pipe(gulpIf(/\.scss/, gulp.dest('app/styles/base')))
.pipe(gulpIf(/\.svg$/, rename('icons.svg')))
.pipe(gulpIf(/\.svg$/, gulp.dest('dist/assets/img/')))
));
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