Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Convert CSS background image paths to Shopify asset paths
var gulp = require('gulp');
var $ = require('gulp-load-plugins')();
var replace = require('gulp-replace');
var rename = require("gulp-rename");
/*
Gulp task to convert CSS background image paths to Shopify asset urls,
e.g. url(/images/background.jpg) -> url({{ 'background.jpg' | asset_url }})
*/
gulp.task('fixurls', function(){
gulp.src(['css/app.css'])
.pipe(replace(/url\(\/?images\/(.+)\)/g, 'url({{ \'$1\' | asset_url }})'))
.pipe(rename("style.css.liquid"))
.pipe(gulp.dest('./css'));
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment