shakyShane / gulp-svg-sprites

Create SVG sprites or compile to <symbols>
MIT License
334 stars 45 forks source link

no-svg class #99

Open saad-mo opened 7 years ago

saad-mo commented 7 years ago

Hello -

The generated CSS created a no-svg class by default.

.no-svg .hyicon:before { background-image: url("../icons.png"); }

is there a way to disable this as I have no need to use PNG fallback in my project.

JamesNock commented 3 years ago

I don't think there is... I've written a regex to remove the css after it's generated:

.pipe(replace(/\.no-svg \.svg-icon\:before\s{[^\r].*sprites\.png\"\);[^\r]}/g, ''))

I thought it might be useful as an aid for anyone else with this issue. My full gulp task is below for context:

var replace = require('gulp-string-replace');
gulp.task('svg:spritesheet:build', function() {
    return gulp.src('src/public/images/svg/*.svg')
        .pipe(svgSprite({
            common: "svg-icon",
            cssFile: "../scss/sprites.scss",
            svg: { sprite: "../images/sprites.svg" },
            svgPath: '/images/sprites.svg',
            preview: false
        }))
        .pipe(replace(/\.no-svg \.svg-icon\:before\s{[^\r].*sprites\.png\"\);[^\r]}/g, ''))
        .pipe(gulp.dest("src/public/images/"));
});