This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 232852 - Add feature to compile a main LESS/SASS file
Summary: Add feature to compile a main LESS/SASS file
Alias: None
Product: web
Classification: Unclassified
Component: CSS Preprocessors (SASS, LESS, ...) (show other bugs)
Version: 7.4
Hardware: All All
: P3 normal with 2 votes (vote)
Assignee: Tomas Mysik
Depends on:
Reported: 2013-07-17 02:09 UTC by xwisdom
Modified: 2017-05-26 22:04 UTC (History)
3 users (show)

See Also:
Exception Reporter:

less testcase (1.58 KB, application/octet-stream)
2015-02-25 16:32 UTC, frank2342

Note You need to log in before you can comment on or make changes to this bug.
Description xwisdom 2013-07-17 02:09:54 UTC
Add feature to compile a main LESS/SASS file regardless of which .less or .scss file is being edited. This would be useful when working on projects like Bootstrap with multiple .less files that compiles to a single .css file
Comment 1 Marek Fukala 2013-07-17 11:55:43 UTC
If such files are included somehow to each other, then the compilation should work when you change any of them. Passing to Tomas, who works on this feature.
Comment 2 Tomas Mysik 2013-07-17 12:27:45 UTC
Could you please attach a sample project? Thanks.
Comment 3 xwisdom 2013-07-18 02:08:37 UTC
Checkout the Bootstrap project at GitHub -

The main file is bootstrap.less which uses @import to include other files. The bootstrap.less while compile to single CSS file in the folder docs/assets/css
Comment 4 Tomas Mysik 2013-07-18 09:07:51 UTC
I just tried it and it works for me as expected - open tooltip.less, change it and save it. The bootstrap.css is recompiled.

Please reopen and describe your scenario since I don't see any reason for this enhancement.


Product Version: NetBeans IDE Dev (Build 20130718-58d6a3ece26d)
Java: 1.7.0_25; Java HotSpot(TM) 64-Bit Server VM 23.25-b01
Runtime: Java(TM) SE Runtime Environment 1.7.0_25-b15
System: Linux version 3.8.0-26-generic running on amd64; UTF-8; cs_CZ (nb)
Comment 5 aex1701 2014-01-27 18:29:10 UTC
I had the same problem. I have edited the included files and the main css file was not compiled. The css file was only compiled when i have changed the main.less file.

My problem was, that i have written "@import '_base';" instead of "@import '_base.less';". When i add the extension ".less" it works without problems.
Comment 6 Tomas Mysik 2014-01-28 08:51:26 UTC
@aex1701: As I wrote, it works for me. And as I wrote, reopen and attach a sample project and describe exact steps to reproduce. Otherwise there is nothing to be fixed here, sorry.

Comment 7 obriat 2014-11-07 10:20:20 UTC

I think that what xwisdom means is  :  when a less project is set to generate only one css file (as in Bootstrap), editing one of the included less file should not generate its css counterpart but just compile the main less file.

So the Netbeans project settings should allow to target files and not just folders.
Then Netbeans should detect included files (by parsing the main files and recursively included ones) or just scan the folder and sub folders where the main less file is located.

Once one of this files is changed only the main less file should be compiled.

For example : 
When using bootstrap ( editing  alerts.less should only trigger bootstrap.less compilation
Comment 8 asauterChicago 2014-12-30 17:24:36 UTC
Is there any news on this? The less compiler is completely unusable at the moment. 

It does recompile the main.less file which includes the @import statements. However, it also recompiles *every other* .less file in the less directory into it's own .css file. 

Just right now I tried the Netbeans less compiler on a project that has 50 .less files.  And it automatically made 100 new css and .map files. Not usable at all.
Comment 9 Tomas Mysik 2015-01-21 11:38:22 UTC
Well, _how_ should be defined that only one CSS file should be generated? Any ideas?

Comment 10 Tomas Mysik 2015-01-28 10:37:29 UTC
(In reply to Tomas Mysik from comment #9)
> Well, _how_ should be defined that only one CSS file should be generated?
> Any ideas?

We need an answer to this question, feel free to reopen and tell us.

Comment 11 jimpansn 2015-02-03 14:17:42 UTC
It would be great if there were two seperate parameters. One defines the .less-file(s) that should be compiled (this could be a main.less or something) 
And a second parameter that defines which files should be watch (any saved changes on these files trigger the compiler, that only compiles the above defined .less-file)
Thats how it works in most other IDEs or editors.
Comment 12 AdamSohn 2015-02-23 06:32:23 UTC
Yes, there should be a configuration to only compile a main LESS/SASS file especially since this is how Bootstrap which is popular functions. All LESS withing a folder should be watched and should only trigger the equivalent of this command, lessc less/style.less > css/style.css

However, it is a minor bug because style.css will be compiled correctly and the other unused CSS files can simply be deleted before being pushed into production.
Comment 13 frank2342 2015-02-25 16:22:48 UTC
(In reply to Tomas Mysik from comment #10)
> (In reply to Tomas Mysik from comment #9)
> > Well, _how_ should be defined that only one CSS file should be generated?
> > Any ideas?
> We need an answer to this question, feel free to reopen and tell us.
> Thanks.

Suggestion 1: Additional field in preprocessor options to set a main file

Suggestion 2: add a comment to every .less file "// main: main.less"
Comment 14 frank2342 2015-02-25 16:32:27 UTC
Created attachment 152218 [details]
less testcase

@font-color: "#000000";

body {
    color: @font-color;

@import "variables.less";
@import "custom.less";

Saving "custom.less" > NameError: variable @font-color is undefined
Saving "main.less" > everything is fine
Comment 15 akdean 2015-03-12 17:48:22 UTC
Found a workaround for this...

Make your less directory look like this:

|  // @import "../src/bootstrap/bootstrap.less";

Then set your "input" folder to be /less/compile in your project configuration settings and all of your "source" documents won't be automatically, however, changing the source files will result in a recompile.

Tested on Windows 8 with Netbeans 8.0.2
Comment 16 Chris_uk 2017-05-26 21:24:20 UTC
I still have this issue in 8.2

I know there is a structural work around to get this working which is fine for a new project.

The problem is when working with existing projects which i do mostly. The developers for the most part are not going to change the structure to add support for one or two IDE that could easily solve the problem themselves.

The best solution in my opinion is an optional field on the settings in project properties. Field to be populated with file name and if left blank keep the existing compile all functionality.

Might be prudent to make it a comma separated list to allow for multiple main files that need compiling.
Comment 17 Chris_uk 2017-05-26 22:04:39 UTC
With the workaround its fine, but doesnt minify the output files either. Could this be a nice feature to expand the module?