less / less.js

Less. The dynamic stylesheet language.
http://lesscss.org
Apache License 2.0
17.02k stars 3.41k forks source link

Less absolute import paths #3488

Closed DenisBratchikov closed 4 years ago

DenisBratchikov commented 4 years ago

Hello. I have problems with absolute imports in less. We have dozens modules in our projects and some style variables are written by other developers, so in my module I need to import their file. I have import in my less file like this:

@import "Platform/style";

The problem is that I can't specify absolute import paths to such imports (I have root dir with all modules) In lib\less\default-options.js I found a necessary option: https://github.com/less/less.js/blob/096dd22a933f32a52ce75c8ca265d249bdfd259c/lib/less/default-options.js#L22 but it doesn't work (VSCode and WebSrorm can't resolve imports, lessc can't execute properly). As I understood in less.cjs.js you use context, but the context doesn't get paths from default-options.js (or from any other place). https://github.com/less/less.js/blob/096dd22a933f32a52ce75c8ca265d249bdfd259c/dist/less.cjs.js#L10132 I tried to push my path to context.paths and it worked good. I also saw you issue, where you specify config.json file (with both typescript and less configurations). Can you tell me the best way to absolute import in less? And does it a bug, that I can't fullfill context.paths?