mrcrowl / vscode-easy-less

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

Option to compile current less file AND main files #67

Closed SteveMcArthur closed 2 years ago

SteveMcArthur commented 4 years ago

I'd like the option to be able to compile both the current less file AND any main files. At the moment it is one or the other.

I found if I edited the code to comment out the return in the LessCompiler.js file, then I got the behaviour I was looking for.

       if (options.main) {
            const mainFilePaths = resolveMainFilePaths(options.main, lessPath, lessFile);
            if (mainFilePaths && mainFilePaths.length > 0) {
                for (const filePath of mainFilePaths) {
                    const mainPath = path.parse(filePath);
                    const mainRootFileInfo = Configuration.getRootFileInfo(mainPath);
                    const mainDefaults = extend({}, defaults, { rootFileInfo: mainRootFileInfo });
                    const mainContent = yield readFilePromise(filePath, "utf-8");
                    yield compile(filePath, mainContent, mainDefaults);
                }
                //return;
            }
       }

So maybe a little option to allow this?

mrcrowl commented 4 years ago

Out of interest, what is the use-case?

SteveMcArthur commented 4 years ago

@mrcrowl I like to have two different css configurations. One with all the individually compiled files and one with the combined (main) file. So the live version of the site has just the combined file and the development version has all the individual files. I know there are other ways of doing this - so this is just my preference for doing things.

corporatereports commented 3 years ago

@SteveMcArthur - I understand this is not what you were requesting, but if you haven't used the source map feature, you might find that you like how this shows up in the browser's dev tools better than having all of the files separated.

Here are my settings in VS Code. Note that sourceMap is set to true: "less.compile": { "main": "main.less", "compress": true, "sourceMap": true, "out": "main.css" }, Also there's more info about it here: https://marketplace.visualstudio.com/items?itemName=mrcrowl.easy-less#project-wide-global-configuration