Skip to content

Commit

Permalink
Perform URL correction in combining stylesheets
Browse files Browse the repository at this point in the history
  • Loading branch information
kriszyp committed Mar 20, 2013
1 parent 42963d2 commit 87f0923
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion build.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,12 @@ function processCss(cssText,basePath){
function insertRule(cssText){
//browserCss.push(cssText);
}
function correctUrls(cssText, path){
var relativePath = pathModule.relative(basePath, pathModule.dirname(path));
return cssText.replace(/url\s*\(['"]?([^'"\)]*)['"]?\)/g, function(t, url){
return 'url("' + pathModule.join(relativePath, url).replace(/\\/g, '/') + '")';
});
}
xstyle.parse.getStyleSheet = function(importRule, sequence, styleSheet){
var path = pathModule.resolve(styleSheet.href, sequence[1].value);
var localSource = '';
Expand All @@ -84,7 +90,7 @@ function processCss(cssText,basePath){
}catch(e){
console.error(e);
}
browserCss.push(localSource);
browserCss.push(correctUrls(localSource, path));
return {
localSource: localSource,
href: path || '.',
Expand Down

0 comments on commit 87f0923

Please sign in to comment.