Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Perform URL correction in combining stylesheets

  • Loading branch information...
commit 87f09236e42f90284da29c558c5c6f72cf230b60 1 parent 42963d2
@kriszyp authored
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 || '.',
Please sign in to comment.
Something went wrong with that request. Please try again.