-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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
Allow creating a source map #1050
Comments
+1 |
2 similar comments
👍 |
+1 |
+2 |
+1 |
+1, obviously! |
+1 |
1 similar comment
+1 |
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. |
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, |
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. |
+1 |
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. ;-) |
+1 very important feature |
You may want to use the SourceMapGenerator here: https://github.com/mozilla/source-map |
I wrote a simple less middleware |
That looks awesome! Aria Stewart On June 18, 2013 at 12:13:41 PM, 安动生 ([email protected]) wrote: |
Thanks for the middleware, i will try this at home. Any way it gets to be
|
+1... +2... +100... This is an incredibly important feature. |
+1 |
3 similar comments
+1 |
+1 |
+1 |
I'm working on this, but its a big job |
+10 |
Thanks for your effort, I think/ hope I speak for all of the plus ones in say that you kick ass for taking on a task that we have not been able to find a solution too. Please let us know if we can help. :) |
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. |
Hi all, this is beautiful, thank you!
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. |
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... |
Even with |
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). |
@dotnetwise to get around the file system bug, there is now an option in the new beta released today to inline the sourcemap (as well as the source files) so that the whole thing is put as a data uri in the generated css file meaning you don't need any extra files. |
hrmm its currently undocumented --source-map=inline is how to do it. |
yes might be better to give its own option.. its a bit confusing having to do
they are too similiar! |
So what are you going to do? Drop the first one and let only '-source-map-inline` do the right thing? (embed original css into the sourcemap itself and point the url on the resulted css to it) ? |
I get the wrong paths in 1.5.0-b4 when I use basepath and rootpath:
This yields a It should read |
@WooDzu it's a Chrome bug. Safari 6.1 does not have this glitch. |
@WooDzu fire a bug to chrome if there is none, this two might be of intrest: or you can search for something diferent: Marco Aurélio D. Campos 2013/10/12 Seph Soliman [email protected]
|
Thanks @scarlac and @madcampos I decided to fire a separate ticket for this as the other 2 are not directly related to the issue. Reference: https://code.google.com/p/chromium/issues/detail?id=307146 |
Demo page: http://umaar.github.io/bootstrap-source-map-example/ (and animation) |
I am super excited about source map support! One thing that would be really nice to support is a way to drop directories from the file path prefixes within the sourcemaps. This is supported in uglifyjs sourcemaps and is very useful: https://github.com/gruntjs/grunt-contrib-uglify#sourcemapprefix |
Is there a way to get the sourcemap from the node/npm module in javascript? |
Should the source map live with the compiled CSS or with the LESS files? All of the examples I've seen have the generated CSS, LESS and index.html all in the same dir. I think many people often have a separate folder for LESS and CSS. Something like this:
If I want my map file to live in
That makes me feel like maybe I'm going against the grain. Is there a best practice around where these things should live? |
i think it should go where it fits your code/management style. for me it Marco Aurélio D. Campos 2013/11/21 Rob Dodson [email protected]
|
I've got the source map working using node.js/grunt but I've found that if I nest an import inside a rule, then all rules inside the imported file are reported as being at the file and line number of the nesting rule. So if file1.less contains: .class1 {
@import 'file2.less';
} and file2.less contains: .class2 {
color: red;
} And HTML like: <div class="class1">
<span class="class2">Some text</span>
</div> Then when inspecting the span it shows up as being line 1 of file1.less not line 1 of file2.less. |
Grunt, all the best ~! |
see sass/sass#569
and #1038
We should output source maps in the new format
The text was updated successfully, but these errors were encountered: