Skip to content

Instantly share code, notes, and snippets.

@foobartel
Created October 15, 2014 03:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save foobartel/f367bd67bc285d382d87 to your computer and use it in GitHub Desktop.
Save foobartel/f367bd67bc285d382d87 to your computer and use it in GitHub Desktop.
Grunt string-replace CSS url to rails asset
// string-replace in two passes, because of bug?, reason is apparently related to lodash template security
// find: ": url(img/imagename)"
//replace: "url(<%= asset_path 'img/imagename' %>)"
'string-replace': {
inline: {
files: {
'dist/css/app.css.erb': ['css/app.css'],
},
options: {
replacements: [{
pattern: /:(\s*)url\((img)(.+?)\)/ig,
replacement: ':$1url(\<%= asset_path \'$2$3\' CLOSETAG)'
},
{
pattern: /CLOSETAG/g,
replacement: '%>'
}]
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment