Skip to content

Allow creating a source map #1050

Closed
Closed

Description

@lukeapage

see sass/sass#569

and #1038

We should output source maps in the new format

Activity

  1. uzikilon commented on Jan 17, 2013

    @uzikilon

    +1

  2. gabeins commented on Jan 17, 2013

    @gabeins

    👍

  3. mrdevinmob commented on Jan 17, 2013

    @mrdevinmob

    +1

  4. matthew-dean commented on Jan 18, 2013

    @matthew-dean
    Member

    +2

  5. madcampos commented on Feb 16, 2013

    @madcampos

    +1

  6. Soviut commented on Feb 16, 2013

    @Soviut

    +1, obviously!

  7. EarMaster commented on Feb 27, 2013

    @EarMaster

    +1

  8. aredridel commented on Feb 27, 2013

    @aredridel

    +1

  9. lukeapage commented on Feb 27, 2013

    @lukeapage
    MemberAuthor

    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.

  10. madcampos commented on Feb 27, 2013

    @madcampos

    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.

  11. lukeapage commented on Feb 27, 2013

    @lukeapage
    MemberAuthor

    @madcampos

    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.

  12. jyonker commented on May 22, 2013

    @jyonker

    +1

  13. matthew-dean commented on Jun 4, 2013

    @matthew-dean
    Member

    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. ;-)

  14. ivan4th commented on Jun 7, 2013

    @ivan4th

    +1 very important feature

  15. ChrisCinelli commented on Jun 10, 2013

    @ChrisCinelli
  16. 96 remaining items

  17. lukeapage commented on Oct 4, 2013

    @lukeapage
    MemberAuthor

    hrmm its currently undocumented

    --source-map=inline

    is how to do it.

  18. lukeapage commented on Oct 4, 2013

    @lukeapage
    MemberAuthor

    yes might be better to give its own option.. its a bit confusing having to do

    --source-map=inline -source-map-inline
    

    they are too similiar!

  19. dotnetwise commented on Oct 4, 2013

    @dotnetwise

    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) ?

  20. aredridel commented on Oct 9, 2013

    @aredridel

    I get the wrong paths in 1.5.0-b4 when I use basepath and rootpath:

    node_modules/less/bin/lessc --source-map --source-map-basepath="`pwd`"/web --source-map-rootpath=/ --strict-imports web/assets/site/css/bootstrap/bootstrap-full.less web/assets/site/css/bootstrap/bootstrap-full.css
    

    This yields a web/assets/site/css/bootstrap/bootstrap-full.css.map, and in the web/assets/site/css/bootstrap/bootstrap.full.css, the last line reads /*# sourceMappingURL=/bootstrap-full.css.map */

    It should read /*# sourceMappingURL=/assets/site/css/bootstrap/bootstrap-full.css.map */

  21. pgasiorowski commented on Oct 12, 2013

    @pgasiorowski

    Greetings. In 1.5.0-b4 while changing styles from debugger the mapping is lost. Is this correct behavior?

    Please see the screenshot:
    less js-sourcemap

  22. scarlac commented on Oct 12, 2013

    @scarlac

    @WooDzu it's a Chrome bug. Safari 6.1 does not have this glitch.

  23. madcampos commented on Oct 12, 2013

    @madcampos
  24. pgasiorowski commented on Oct 14, 2013

    @pgasiorowski

    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

  25. blittle commented on Oct 23, 2013

    @blittle

    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

  26. mquandalle commented on Nov 4, 2013

    @mquandalle

    Is there a way to get the sourcemap from the node/npm module in javascript?

  27. robdodson commented on Nov 22, 2013

    @robdodson

    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:

    css/
      index.css
    less/
      index.less
      foo.less
      bar.less
    index.html
    

    If I want my map file to live in css/ I have to use a bunch of settings to iron it all out.

    lessc less/index.less > css/index.css \
    --source-map css/index.css \
    --source-map-rootpath=../less \
    --source-map-url=index.css.map
    

    That makes me feel like maybe I'm going against the grain. Is there a best practice around where these things should live?

  28. madcampos commented on Nov 22, 2013

    @madcampos

    i think it should go where it fits your code/management style. for me it
    would be in the map folder inside the public directory of my app (my less
    files are not in the public directory of the app, it's elsewere).

    Marco Aurélio D. Campos
    Instituto de Computação - UFMT

    2013/11/21 Rob Dodson [email protected]

    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:

    css/
    index.css
    less/
    index.less
    foo.less
    bar.less
    index.html

    If I want my map file to live in css/ I have to use a bunch of settings
    to iron it all out.

    lessc less/index.less > css/index.css
    --source-map css/index.css
    --source-map-rootpath=../less
    --source-map-url=index.css.map

    That makes me feel like maybe I'm going against the grain. Is there a best
    practice around where these things should live?

    —
    Reply to this email directly or view it on GitHubhttps://github.com//issues/1050#issuecomment-29043445
    .

  29. aBrookland commented on Dec 3, 2013

    @aBrookland

    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.

  30. vdegenne commented on Mar 25, 2015

    @vdegenne

    Grunt, all the best ~!

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions