Skip to content

Loader fails on SVG definition rules with URL values #26

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

Closed
BarakChamo opened this issue Dec 2, 2014 · 5 comments
Closed

Loader fails on SVG definition rules with URL values #26

BarakChamo opened this issue Dec 2, 2014 · 5 comments

Comments

@BarakChamo
Copy link

This is an issue moved from less-loader after opening it there by mistake:
webpack-contrib/less-loader#25

The loader seems to break when styles include references to SVG definitions. I'm using the markers in the styles because I don't want to mess with the charting library I'm using but the loader breaks on the URL.

Marker definition:

<defs>
    <marker id="line-marker">
         <circle cx="6" cy="6" r="5"></circle>
    </marker>
</defs>

Marker use:

path.nv-line {
    marker-mid: url('#line-marker');
}

Is there a way of ignoring some URL values in these rules or another way to prevent the loader from failing?

@jhnns
Copy link
Member

jhnns commented Dec 2, 2014

That's the line responsible. What exactly doesn't work?

I've added a test which confirms that this should work.

@BarakChamo
Copy link
Author

The problem is that this reference is not to a file but to a definition in the SVG,
inside <defs> and should not be interpreted yet there is an error:

Error: Cannot resolve directory

Are hash-first urls meant to be ignored or assumed to be shorthand for the current location?

@BarakChamo
Copy link
Author

I looked into the part you pointed out, it seems that at that point the URL is already augmented:

In the stylesheet (chart.less inside 'component/' folder):

path.nv-line {
    marker-mid: url('#line-marker');
}

In the loader:

    var url = loaderUtils.parseString(match[2]);
    console.log(url);
    >> components/#line-marker

@BarakChamo
Copy link
Author

Seems to be an issue with less.js, reported there in less/less.js#2320

Thanks!

@jhnns
Copy link
Member

jhnns commented Dec 2, 2014

Anyway, thx for reporting 👍

koistya pushed a commit to koistya/css-loader that referenced this issue Nov 19, 2015
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

2 participants