I'm using Visual Studio 2010, .NET 4 and MVC 2 on this project with YUI Compressor running as a post build event.
The thing is we had one big css file which was not maintainable so we've split it into many CSS files in different folders.
Something like that.
This is good for development but not for production. On production we only have 1 file, which is a merged/minified version of everything, this file sits at /Assets/Styles/style.css
Now this design is causing problem because the image paths can't be the same in dev and prod. (we also have staging and uat but lets keep things simple)
I see a few solutions to that, we could use absolute paths, we could have many minified/merge css files and put them in the right folder (Pages.css / Partials.css) or we could use a cookie-free subdomain (static.domain.com) which is what I would like to do.
So my question is: How do I automatically rename "../../image.png" to "http://static.domain.com/image.png" in my CSS files automatically?? Can YUI Compressor do that? Should I make a build console projects that does just that? Do you know a tool that will do that for me? Other suggestions?!
Thanks in advance!
YUI-compressor can not do that.
You need to loop over the files and replace every path with the new absolut path. You can easily do this with a regex. I don't know if you can do this easily in windows-batch but it's easy with unix sed or any script (perl, python...). If you are more familiar with .NET you can build a console project and run it as a post build event.
Hope this helps.