Skip to content

Compatibility with Chrome's Sass support - #1038

Closed
fgnass wants to merge 2 commits into
less:masterfrom
fgnass:master
Closed

fgnass wants to merge 2 commits into
less:masterfrom
fgnass:master

Conversation

@fgnass

@fgnass fgnass commented Nov 14, 2012

Copy link
Copy Markdown
Contributor

Chrome DevTools now have experimental support for Sass-style line-number annotations but they are a little picky about the exact formatting.

This pull-request modifies the -sass-debug-info output to 100% match the syntax emitted by Sass itself which effectively gives us source-mapping for .less files in Chrome.

In order to be picked up by Chrome …

  1. the filename must be a file:// URL
  2. the path must be escaped rather than quoted

screenshot

In order to make the debug info compatible with
Chrome's built-in experimental Sass support:

1) The filename must be a file:// URL
2) The path must be escaped rather than quoted
Comment thread lib/less/tree.js

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@fgnass

fgnass commented Nov 15, 2012

Copy link
Copy Markdown
Contributor Author

In CSS leading digits must be escaped as Unicode code point, so 1 which is U+0031 becomes \000031.

@paulirish

Copy link
Copy Markdown

just to assuage any concerns..

There is generalized support in Chrome DevTools for v3 sourcemaps for CSS. This allows for mapping back to the original mixin/variable/expression for any given aspect of the compiled CSS.

This line-number mapping was a short-term solution to explore the idea and get feedback from users on how to deliver this feature.

The long term solution is that less.js generates v3 sourcemaps and get the full benefit of line/prop/value mapping with devtools UI support. I talked about this on eps 2 and 3 of The Breakpoint if anyone wants to hear more about it.

@matthew-dean

Copy link
Copy Markdown
Member

Thanks @paulirish! I had asked Paul on Twitter if there were was a "more generic" way to support pre-processed CSS so that we didn't have to emulate SASS. Apparently, there is. Can someone look into the v3 sourcemaps so that we can possibly migrate LESS to a more generic syntax?

@fgnass

fgnass commented Nov 21, 2012

Copy link
Copy Markdown
Contributor Author

With the Mozilla source-map module generating a source-map is pretty easy. The problem is that in tree.debugInfo we currently only know the original location but not the generated one. To make this work we would probably have to refactor the toCSS method, but I don't really know the less codebase well enough to say if this would indeed be the best place.

@lukeapage

Copy link
Copy Markdown
Member

I think it needs some heavy refactoring. Maybe splitting the toCSS visit of the nodes into a generateCSS visit and then a visitor that can add inline debugging, then one that can generate source maps, then one that outputs the css. It would be nice to change to a visitor pattern to do these so the stages can be easily plugged in.

I suggest pulling this for now and starting work on the refactoring so that source maps might be possible eventually.

@lukeapage

Copy link
Copy Markdown
Member

this is pulled and a raised a new feature for v3 sourcemaps. also fixed tests as they no longer passed on windows.

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

Successfully merging this pull request may close these issues.

4 participants