Commit 4883c5cc authored by Nikolay Gromov's avatar Nikolay Gromov

Подправил задачу сборки SVG спрайта (не собирается, если не использован)

parent d49c925b
...@@ -134,36 +134,42 @@ gulp.task('copy:fonts', function () { ...@@ -134,36 +134,42 @@ gulp.task('copy:fonts', function () {
// Сборка SVG-спрайта для блока sprite-svg // Сборка SVG-спрайта для блока sprite-svg
gulp.task('sprite:svg', function (callback) { gulp.task('sprite:svg', function (callback) {
const svgstore = require('gulp-svgstore'); if((pjson.configProject.blocks['sprite-svg']) !== undefined) {
const svgmin = require('gulp-svgmin'); const svgstore = require('gulp-svgstore');
const cheerio = require('gulp-cheerio'); const svgmin = require('gulp-svgmin');
let spritePath = dirs.srcPath + dirs.blocksDirName + '/sprite-svg/svg/'; const cheerio = require('gulp-cheerio');
if(fileExist(spritePath) !== false) { let spritePath = dirs.srcPath + dirs.blocksDirName + '/sprite-svg/svg/';
console.log('---------- Сборка SVG спрайта'); if(fileExist(spritePath) !== false) {
return gulp.src(spritePath + '*.svg') console.log('---------- Сборка SVG спрайта');
.pipe(svgmin(function (file) { return gulp.src(spritePath + '*.svg')
return { .pipe(svgmin(function (file) {
plugins: [{ return {
cleanupIDs: { plugins: [{
minify: true cleanupIDs: {
} minify: true
}] }
} }]
})) }
.pipe(svgstore({ inlineSvg: true })) }))
.pipe(cheerio(function ($) { .pipe(svgstore({ inlineSvg: true }))
$('svg').attr('style', 'display:none'); .pipe(cheerio(function ($) {
})) $('svg').attr('style', 'display:none');
.pipe(rename('sprite-svg.svg')) }))
.pipe(size({ .pipe(rename('sprite-svg.svg'))
title: 'Размер', .pipe(size({
showFiles: true, title: 'Размер',
showTotal: false, showFiles: true,
})) showTotal: false,
.pipe(gulp.dest(dirs.srcPath + dirs.blocksDirName + '/sprite-svg/img/')); }))
.pipe(gulp.dest(dirs.srcPath + dirs.blocksDirName + '/sprite-svg/img/'));
}
else {
console.log('---------- Сборка SVG спрайта: ОТМЕНА, нет папки с картинками');
callback();
}
} }
else { else {
console.log('---------- Сборка SVG спрайта: нет папки с картинками'); console.log('---------- Сборка SVG спрайта: ОТМЕНА, блок не используется на проекте');
callback(); callback();
} }
}); });
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment