Skip to content
Browse files

Perform URL correction in combining stylesheets

  • Loading branch information...
1 parent 42963d2 commit 87f09236e42f90284da29c558c5c6f72cf230b60 @kriszyp committed Mar 20, 2013
Showing with 7 additions and 1 deletion.
  1. +7 −1 build.js
View
8 build.js
@@ -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 = '';
@@ -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 || '.',

0 comments on commit 87f0923

Please sign in to comment.
Something went wrong with that request. Please try again.