-
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
Sourcemap basepath option #1543
Conversation
@@ -197,7 +202,7 @@ if (output) { | |||
} | |||
} | |||
|
|||
options.sourceMapBasepath = process.cwd(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if the only change that instead of being process.cwd()
this should be the directory of the root less file.. then we are stripping this off every path and adding in the sourcemap rootpath.. would that work for you too?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure I understand. Backing out my change and only removing this line gives me lots o "/ns/(davMountpoint)/..." still in the paths.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, try replacing this with options.sourceMapBasepath = input ? path.dirname(input) : process.cwd()
If you could let me know if that works, that would be great
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That may work if all less files are in a subdirectory relative the input file. But my setup is like this:
/css/src/main.less
/css/prd/main.css
/css/vendor/bootstrap/
main.less does things like @import ../vendor/boostrap/less/variables.less
and all output is placed in /css/prd/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It also only works if the "sources" references in the source map are relative, but I'm adding the rootpath prefix "/ns/" witch leads to paths like "/ns/main.less" where it should be "/ns/css/src/main.less".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll take this pull request thanks, but also change the default in the way I suggested.
Excellent. The source maps are working very good by the way. 👍 |
Just referenced #1740 to this one. Perhaps the basepath could help with the problem of being able to remove preceding parts of the paths written in the generated sourcemap file. Cheers. |
I failed to create a correct source map unless standing in exactly right directory when running the lessc command.
I've added a --source-map-basepath option that is used in stead of process.cwd() if supplied, and also normalizing the path printed in the sourceMappingURL.
This is something that works for me right now, but I'm not sure it is the right thing to do. I have not tested it in other configurations. Merge with caution.
I can now invoke the command from my Gruntfile.js like this: