Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Configure path.sep globally #6

Open
eduardoarantes opened this issue Jul 9, 2014 · 1 comment
Open

Configure path.sep globally #6

eduardoarantes opened this issue Jul 9, 2014 · 1 comment

Comments

@eduardoarantes
Copy link

My css is like this
body {
letter-spacing: -0.3px;
background: url("../images/outer_bg.jpg") repeat;
}

after bbb-styles executes it became

body {letter-spacing: -0.3px; background: url("/app\images\outer_bg.jpg") repeat;}

See the backslash.

It fails loading on the browser

I'm using windows 8

It happens on path.join()

Is it possible to set path.sep globally for nodeJs?

regards

@eduardoarantes eduardoarantes changed the title Styles generating empty file Configure path.sep globally Jul 9, 2014
@eduardoarantes
Copy link
Author

I've addressed this issue and other that I have faced
Definitions like"
@font-face {font-family: "ProximaNovaLight";src: url("fonts/proximanova-light-webfont.eot");src: url("fonts/proximanova-light-webfont.eot?iefix") format("embedded-opentype"), url("fonts/proximanova-light-webfont.woff") format("woff"), url("fonts/proximanova-light-webfont.ttf") format("truetype");font-weight: normal;font-style: normal;}

were not addressed.

In order to fix I change the code of the method as below

function additionalProcessing(css, filepath) {
  var stylesheet = cssom.parse(css);
  var url = /url\([\'"]?(.[^\'"]*)?[\'"]?\)/g;
  var dir = path.dirname(filepath);
  var rel = options.forceRelative;

  function processRules(cssRules) {
    cssRules.forEach(function(rule) {
      // Iterate over all styles and find all `url` values.
      [].slice.apply(rule.style || []).forEach(function(key) {
        var value = rule.style[key];
        var match;

        // Replace the image paths.
        while (match = url.exec(value)) {
          // Ignore base64.
         if (value.indexOf("base64") === -1) {
             value = value.replace(match[1], rel + path.join(dir, match[1]));
             rule.style[key] = value.replace(/\\/g, "/");

         }
        }
      });

      if (rule.cssRules) {
        processRules(rule.cssRules);
      }
    });
  }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant