Skip to content

@import directive in an already @import'd file uses full url with hash as base #134

@dbergey

Description

@dbergey

My page's url looks like this, with a hash in the middle: http://mysite.com/#/controller/function/

In a <style> tag on the main page, I have (which works fine):

@import "/assets/main.less";

Inside main.less is another @import without a path:

@import "include.less"

The browser requests it as "http://mysite.com/#/controller/function/include.less", disregarding the hash. I have discovered that if I comment out the block:

// Stylesheets in IE don't always return the full path
if (! /^(https?|file):/.test(href)) {
    href = url.slice(0, url.lastIndexOf('/') + 1) + href;
}

...it works, and I have worked around it for now in Safari by adding a second condition thusly:

// Stylesheets in IE don't always return the full path
if (! /^(https?|file):/.test(href) && /msie/.test(navigator.userAgent)) {
    href = url.slice(0, url.lastIndexOf('/') + 1) + href;
}

...but that is of course not a good long-term solution, and probably doesn't fix the issue in IE.

Being unfamiliar with the less.js codebase, I'm not sure what or where the problem is. Help?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions