You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
you should be able to use this to go over the nodes and grab original input information.
What you don't know is the target (css) line number.
To do that I would suggest having functions on the toCSS env object which build up the css and keep track of the current line number. You can then store that line number against the node.
i'm not good at compiler theory (in fact i am at this course at college now) and haven't looked up less' code, but can't just write to a variable say, lineNumber and at each line break increment it? it should keep the line number state, after that it could be exposed to the function mapping the lines.
yes.. that is this bit of the implementation I described.
having functions on the toCSS env object which build up the css and keep track of the current line number.
you need to keep track of the line number on the env object but also store its current value against each node as you output the css, then the ast has the source and the target line numbers and a mapping can be made.
@duncanmcdowell Looks like you just forget to install it globally. In case you are on Ubuntu or the like as well and use chromium and followed the sandbox thing I described above, I was able to handle that in a better way now.
I also recommend using the npm install -g less@beta rather then pointing to some files on github since this works fine and will pull always the most up to date beta.
@nextgenthemes thank you for your blogpost. it helped me getting it running with webstorm. i installed the latest less beta and have the following settings in webstorm file watcher:
For those using CodeKit.app I can recommend writing a small node.js script and using that script as the "compiler" for the 1.5 beta. That way you don't have to recompile it manually to get sourcemaps. My script seems to work for me, but it may contain bugs or needs to be adjusted for your environment. https://gist.github.com/scarlac/6793066
Hi all, this is beautiful, thank you!
Here's the steps I followed to get it working for my dev env:
Chrome v30 (I have Version 30.0.1599.66 to be exact)
I ensured that in Chrome Gears->General both these are checked: "Enable CSS source maps" and "Auto-reload generated CSS"
I got the latest lessc 1.5 beta from node: "sudo npm install -g less@beta"
Install worked fine (once lessc 1.5 is released then no need to do this I assume)
I build using lessc: "lessc --line-numbers=all --source-map=main.css.map main.less >main.css"
I reload my app and can debug the less styles. I load from localhost hitting apache to serve my html and files, I understand from previous comments that files must be served from a web server, cannot be loaded direct from filesystem.
tip: type "lessc" to --line-numbers and --source-map choices
The --source-map setting was critical for me to get it working. I set it to follow the filename of my final generated css.
Even with -allow-file-access-from-files the css source maps are still not being loaded in Chrome canary 32.0.1658.2 when opening html files via file:// protocol. Javascript source map do load.
To whoever still can't figure out how to make it work, this might save few hours of debug.
If you use webserver, you should define --source-map-rootpath options to be equal to your website base path. For example, if you debug http://website.com/styles/style.css (and the less file is present at the same location, e.g. http://website.com/styles/style.less), here's how you compile command should look like:
this should be a full URL to the source map, which could be opened in chrome. It it's correct, everything should work fine. If not, keep playing with arguments.
I can confirm this with less v.1.5b3, Chrome 29 and Canary 32 (with no special command line arguments).
Activity
uzikilon commentedon Jan 17, 2013
+1
gabeidx commentedon Jan 17, 2013
👍
mrdevinmob commentedon Jan 17, 2013
+1
matthew-dean commentedon Jan 18, 2013
+2
madcampos commentedon Feb 16, 2013
+1
Soviut commentedon Feb 16, 2013
+1, obviously!
EarMaster commentedon Feb 27, 2013
+1
aredridel commentedon Feb 27, 2013
+1
lukeapage commentedon Feb 27, 2013
if anyone wants to work on this
https://github.com/cloudhead/less.js/tree/import-interpolation
now has a visitor pattern implemented.
you should be able to use this to go over the nodes and grab original input information.
What you don't know is the target (css) line number.
To do that I would suggest having functions on the toCSS env object which build up the css and keep track of the current line number. You can then store that line number against the node.
After that it should be simple.
madcampos commentedon Feb 27, 2013
i'm not good at compiler theory (in fact i am at this course at college now) and haven't looked up less' code, but can't just write to a variable say,
lineNumber
and at each line break increment it? it should keep the line number state, after that it could be exposed to the function mapping the lines.lukeapage commentedon Feb 27, 2013
@madcampos
yes.. that is this bit of the implementation I described.
you need to keep track of the line number on the env object but also store its current value against each node as you output the css, then the ast has the source and the target line numbers and a mapping can be made.
jyonker commentedon May 22, 2013
+1
matthew-dean commentedon Jun 4, 2013
lol, we're all for it, looks like we just need an adept JavaScript / LESS programmer to fix it up and do a pull request. ;-)
100 remaining items
nextgenthemes commentedon Sep 16, 2013
@duncanmcdowell Looks like you just forget to install it globally. In case you are on Ubuntu or the like as well and use chromium and followed the sandbox thing I described above, I was able to handle that in a better way now.
I also recommend using the
npm install -g less@beta
rather then pointing to some files on github since this works fine and will pull always the most up to date beta.I have written up a more detailed HowTo to make this work on Ubuntu and friends. Check it out, I hope this helps somebody. http://nextgenthemes.com/2013/09/howto-get-less-sourcemaps-to-work-in-ubuntu-with-chromium/
hansipete commentedon Sep 24, 2013
@nextgenthemes thank you for your blogpost. it helped me getting it running with webstorm. i installed the latest less beta and have the following settings in webstorm file watcher:

scarlac commentedon Oct 2, 2013
For those using CodeKit.app I can recommend writing a small node.js script and using that script as the "compiler" for the 1.5 beta. That way you don't have to recompile it manually to get sourcemaps. My script seems to work for me, but it may contain bugs or needs to be adjusted for your environment.
https://gist.github.com/scarlac/6793066
denisos commentedon Oct 2, 2013
Hi all, this is beautiful, thank you!
Here's the steps I followed to get it working for my dev env:
Install worked fine (once lessc 1.5 is released then no need to do this I assume)
tip: type "lessc" to --line-numbers and --source-map choices
The --source-map setting was critical for me to get it working. I set it to follow the filename of my final generated css.
seven-phases-max commentedon Oct 2, 2013
Btw., Chrome has "-allow-file-access-from-files" command line option so it's actually possible to test/debug your pages w/o a web server...
dotnetwise commentedon Oct 3, 2013
Even with
-allow-file-access-from-files
the css source maps are still not being loaded in Chrome canary32.0.1658.2
when opening html files viafile://
protocol. Javascript source mapdo
load.neochief commentedon Oct 3, 2013
To whoever still can't figure out how to make it work, this might save few hours of debug.
If you use webserver, you should define --source-map-rootpath options to be equal to your website base path. For example, if you debug http://website.com/styles/style.css (and the less file is present at the same location, e.g. http://website.com/styles/style.less), here's how you compile command should look like:
If it still does not work, check your generated css file. At the very bottom it should have something like this:
this should be a full URL to the source map, which could be opened in chrome. It it's correct, everything should work fine. If not, keep playing with arguments.
I can confirm this with less v.1.5b3, Chrome 29 and Canary 32 (with no special command line arguments).
25 remaining items