mrcrowl / vscode-easy-less

Easy LESS extension for Visual Studio Code
MIT License
67 stars 23 forks source link

Compile any instance of a file name, regardless of folder it is in #60

Closed kevadamson closed 4 years ago

kevadamson commented 4 years ago

Is this possible? For example I have many instances of "layout.less" in various folders. I would like them to compile each time another less file is saved, without having to manually add each instance to "main:". Does that make sense?

mrcrowl commented 4 years ago

That depends. If the "layout.less" files are the only less files that you want to compile, then this can be achieved by using the main setting in the settings.json file:

{    
    "less.compile": {
        "main": ["${workspaceRoot}/folder1/layout.less", "${workspaceRoot}/folder2/layout.less"]
    }
}

If you have other less files that you want to auto-compile, then the situation is somewhat more complicated, unfortunately.

When a main file is specified at the settings level, then it applies to all less files within your project.

kevadamson commented 4 years ago

Thanks for the speedy response. I could, in theory, end up with a lot of main declarations (the project I'm working on could have a lot of "skins"), so I was hoping there might be a declaration like:

"main": ["${workspaceRoot}/*/*/layout.less"]

Where * is any named folder. So I don't have to repeat each time. Make sense?

mrcrowl commented 4 years ago

Yeah, it makes sense. Unfortunately not supported, and I'm unlikely to implement because using glob patterns will incur a search cost every time a less file is saved (... or alternatively, easyless would need to keep track of all files named layout.less that match the pattern).

You might be interested in a more advanced solution such as gulp-less or webpack.