profile
viewpoint

Ask questionsHow to use it with Gulp?

I want to replace all lines 'img/sprite.png' with on strings '../img/sprite.png' The lines are in the file (style.min.css) I am doing something wrong... I have errors, please help me

0

function fixSprites() {
    const results = replace.sync({
        files: config.build.style + '/style.min.css',
        from: 'img/sprite.png',
        to: '../img/sprite.png',
        countMatches: true,
    })
    return src(config.build.style + '/style.min.css')
        .pipe(replace(results))
}

exports.fixSprites = fixSprites()
adamreisnz/replace-in-file

Answer questions brendan8c

This is the out of the box gulp solution Replace all lines of a similar type with others. Example: replace img/sprite.png with ../img/sprite.png

2021-06-06 02_02_30-gulpfile js - start_gulp - Visual Studio Code  Не поддерживается

const { series } = require('gulp')
const replace = require('replace-in-file')

function updateRedirects(done) {
    replace({
        files: 'build/css/style.min.css',
        from: /img\/sprite.png/g, // img/sprite.png – Replace this.
        to: '../img/sprite.png', // ../img/sprite.png – Replace with this.
        countMatches: true,
    }, done)
}

exports.build = series(updateRedirects) // Start
useful!

Related questions

No questions were found.
source:https://uonfu.com/
Github User Rank List