gulp-inline-source
gulp-inline-source copied to clipboard
Support for rewriting CSS-URLs
It would be awesome if urls in stylesheets would be rewritten when embedded.
.div {
background: url('../images/background.jpg');
}
should become
.div {
background: url('static/images/background.jpg');
}
This probably needs a new config option to define the path to use for rewriting.
+1
+1 I can't use this plugin without this functionality, please consider it!
https://github.com/popeindustries/inline-source/issues/30 I've added a new issue to the original plugin for this and am willing to write it, I will post any updates here :+1:
You can make your own stream by using gulp-rework with rework-plugin-url :)
like this (note that script is written in coffeescript):
$.rebaseCSSUrl = $.lazypipe()
.pipe () ->
return $.rework $.reworkUrl (url) ->
return url if url.match /^data:/i # keep url if url is Data URI
return url if url.match /^http/i # keep url if url is Full URL
return url if url.match /^\// # keep url if url is absolute path
# remove all of parent path references
# and prepend asset path
return '/assets/bower-assets/' + $.path.basename url
After creating your own stream, just pipe it before inline-source stream.
@fmal Answered :)