The task fails to rewrite URLs if the asset is not present. While processing the stylesheet the code does :
// If that didn't work, try finding the image relative to
// the current file instead.
if(!fs.existsSync(loc)) {
    loc = path.resolve(__dirname + img);
}
This not only makes it cumbersome to integrate on the grunt build system, as i have to create a number of temporary directories and copy the assets there, just to delete everything afterwords, as it creates a totally bogus location if those assets are not actually there.