Skip to content

Instantly share code, notes, and snippets.

@foobartel
Created August 2, 2016 09:36
Show Gist options
  • Save foobartel/1335d11e0a88f42060a6f6111c081f42 to your computer and use it in GitHub Desktop.
Save foobartel/1335d11e0a88f42060a6f6111c081f42 to your computer and use it in GitHub Desktop.
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