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

Does not apply objectUrl for <link> tag when setting sourceMap: true #265

Closed
Aqours opened this issue Sep 26, 2017 · 5 comments · Fixed by #383
Closed

Does not apply objectUrl for <link> tag when setting sourceMap: true #265

Aqours opened this issue Sep 26, 2017 · 5 comments · Fixed by #383

Comments

@Aqours
Copy link

Aqours commented Sep 26, 2017

Move from: css-loader with sourceMap: true cause adding style tag delayed

Actually, above issue is caused by style-loader.

if (sourceMap) {
// http://stackoverflow.com/a/26603875
css += "\n/*# sourceMappingURL=data:application/json;base64," + btoa(unescape(encodeURIComponent(JSON.stringify(sourceMap)))) + " */";
}
var blob = new Blob([css], { type: "text/css" });
var oldSrc = link.href;
link.href = URL.createObjectURL(blob);

I have an idea to resolve this issue, but it's not perfect. Consider to apply this solution.

My solution code:
Using code link.href = 'data:text/css;base64,' + btoa(encodeURIComponent(css)); replace line 363.

Test:

  • Chrome 61: √
  • Edge: √
  • IE 11: √
  • Firefox 55: × Bug(maybe)
  • Safari: √
@Aqours Aqours changed the title [Bug & Proposal] does not apply blob for <link> tag when setting sourceMap: true [Bug & Proposal] does not apply objectUrl for <link> tag when setting sourceMap: true Sep 26, 2017
@alexander-akait
Copy link
Member

alexander-akait commented Sep 26, 2017

@Aqours thank for issue, maybe best to wait when bug was fixed in firefox than change right source code?

@Aqours
Copy link
Author

Aqours commented Sep 27, 2017

@evilebottnawi can you provide a flag(e.g: options.debug: true) to enable this feature? so we can debug less/sass source code.

@alexander-akait
Copy link
Member

@d3viant0ne what do you think about this issue?

@WraithKenny
Copy link

WraithKenny commented Nov 10, 2017

I stumbled across this issue, not because of loading delays, but because the sourcemap doesn't actually work. In your tests, was the sourcemap actually loading, or just the stylesheet?

In my test, the stylesheet loads, but the styles in the firefox inspector point to the blob:null/ location, instead of the source file name. Additionally, it doesn't load the source file in the panel when you click on it.

This works correctly in Chrome. It looks like mozilla closed the referenced ticket as invalid. Maybe worth revisiting it?

(edit: or, it might be because I'm loading the html from file:/// Maybe Firefox just breaks for some reason in that case...)

@michael-ciniawsky michael-ciniawsky added this to the 1.0.0 milestone Jan 26, 2018
@michael-ciniawsky michael-ciniawsky changed the title [Bug & Proposal] does not apply objectUrl for <link> tag when setting sourceMap: true Does not apply objectUrl for <link> tag when setting sourceMap: true Jan 26, 2018
@wxlworkhard
Copy link

Why use <link> replace <style> when sourceMap: true ? <link> cannot load url() asset on Chrome.

Why not just use

css += "\n/*# sourceMappingURL=data:application/json;base64," +
            btoa(unescape(encodeURIComponent(JSON.stringify(sourceMap)))) + " */";

and

styleElement.appendChild(document.createTextNode(css));

in addStyles.js file. This is simple and have no problem.

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

Successfully merging a pull request may close this issue.

5 participants