ndeet / plg_system_less

A Joomla! system plugin to compile .less files on the fly.
GNU Lesser General Public License v3.0
17 stars 13 forks source link

Process multiple .less files #8

Closed TerryIrata closed 10 years ago

TerryIrata commented 11 years ago

Hi,

I have been trying out various ways to use LESS with Joomla and this plug in is pretty close to the easiest to implement and use however it is limiting that it can only process one .less file and the plug in needs to be updated to process a different name.

My suggestion for improving your extension would be to allow directories to be specified for the input and output files, rather than specific files, and then process whatever .less files it find in the directory.

For example; Input Directory: template/mytemplate/less/ contains file1.less, file2.less, file3.txt, file4.less

plg-system_less is invoked and reads each of the .less files it finds and creates a processed .css file in the output directory.

Output: template/mytemplate/css/ now contains file1.css, file2.css, file4.css

This would provide more flexibility and allow your extension to be used more widely with templates that have separate CSS files for layout, typography, customisations.

Regards, Terry

ndeet commented 11 years ago

Hi Terry!

Thanks for your suggestions, appreciate it.

The main reason why only one .less file can be choosen as input is because e.g. the main template.less file includes all other less files and the output is a single .css file with all less files combined. That's how it is working now. If you want your custom.less compiled you only have to include it in your main .less file (e.g. template.less).

But you are right there maybe a use case for separate .less files as well. The question is how to detect if a .less file has been included and does not need to be compiled again. The easy way would be to add an option to compile all .less files - but then you will end up with a combined template.css and separate .css files for each .less file. So, there will be some duplicates. But maybe a worth a try.

I have to think about how to handle this a bit more.

Klipper commented 11 years ago

For load-time and data-consumption of a browser it is much better to put all your CSS in one single .css file. Less http requests to server and less overhead. Mobile devices don't like multiple http requests...

stadscript commented 11 years ago

For custom less bootstrap templates, multiple less files are needed, but only one other.

So I would suggest a main "template" less file and also an optional "responsive" less file.

Including the Joomla 3.x bootstrap file works, but you don't want to customize it directly, and overriding classes in your own file can lead to so many problems, customizing your own bootstrap template is always the best option in this case. By doing 2 files you can combine your less files with bootstraps, meaning only 2 files if you enable responsive, with only a click to disable responsive.

w9914420 commented 11 years ago

So in essence you would need to have another instance of the autocComplieLess function and then you could have whatever less file you wanted. I have to disagree that having an input directory would be a bit problematic. Have one less file and import the others in.

stadscript commented 11 years ago

Yes Importing is always the best option, and bootstrap 3 may fix the main issue with having to use 2 files (if you do not use 2 files then responsive will override the main).

I am a big fan of "one file" but if your using bootstrap 2.x and want to use your own less files, this plugin currently cannot do that. If I get time I might try to do a modification to add it, but for now with how I code, although a dream come true this is not useful to me.

ndeet commented 10 years ago

Closing the issue for now. Feel free to reopen if somebody want to make it work.