N
N
Nicholas2019-10-13 13:55:45
Automation
Nicholas, 2019-10-13 13:55:45

Why don't images from svg sprite open the first time?

Hello! I ran into this problem:
some kind of leapfrog with the gulp-svg-sprite plugin, the image from the sprite is not displayed until you go and open some image from this sprite in the browser, while the files that are made through the settings shape: { dest: "intermediate-svg"}behave the same.
Once again, how it does not work:
Go to the page: sedona.u0718915.isp.regruhosting.ru - we see that the svg image (welcome) inserted through background css is not displayed in the header.
We go to the address: sedona.u0718915.isp.regruhosting.ru/img/svg/sprite...
and we see that the picture opens, further, !In the same tab! remove part of the path and leave sedona.u0718915.isp.regruhosting.ru- and move on, and .. see that everything works (welcome picture) appeared!
What could it be?
ps this behavior is noticed only when working through css or the img tag, it opens immediately through the svg tag.
Thanks to all who responded!
-
svg task code:

let svgSprite = require('gulp-svg-sprite'),
    svgmin = require('gulp-svgmin'),
    cheerio = require('gulp-cheerio'),
    replace = require('gulp-replace'),
    browsersync = require('browser-sync'),
    debug = require('gulp-debug'),

    svgPath = {
        "input": "./source/pictures/svg/*.svg",
        "output": "./public/img/svg/"
    };

module.exports = function () {
    $.gulp.task('svg', () => {
        return $.gulp.src(svgPath.input)
            .pipe(svgmin({
                js2svg: {
                    pretty: true
                }
            }))
            .pipe(cheerio({
                run: function ($) {
                    $('[fill]').removeAttr('fill');
                    $('[stroke]').removeAttr('stroke');
                    $('[style]').removeAttr('style');
                },
                parserOptions: {xmlMode: true}
            }))
           .pipe(replace('>', '>'))
            .pipe(svgSprite({
                inline: true,
              shape: {
                dest: "intermediate-svg"
            },
            mode: {
                stack: {
                    sprite: "../sprite.svg"
                }
            }
            }))
            .pipe($.gulp.dest(svgPath.output))
            .pipe(debug({
              "title": "Sprites"
          }))
            .on("end", browsersync.reload);
   });
};

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
Nicholas, 2019-10-13
@devaide

It's decided. It's about the svg files themselves. The question is closed

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question