Created
October 15, 2014 03:06
-
-
Save foobartel/f367bd67bc285d382d87 to your computer and use it in GitHub Desktop.
Grunt string-replace CSS url to rails asset
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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