Using less css framework in production

A few weeks ago I found out about LESS CSS. And this is exactly what I was thinking about, should be available when writing css code.

Now I really want to use it and I want to apply this in a production scenario, but there is a trick. To use LESS CSS, you have two options:
1. Include less.js on your web pages.
2. Compose the LESS files first , and then use them.

The first option, which I can not afford, because for this I need to use less.js up to 43 KB in size. This extra load when I already use jQuery.

The second option looks promising, but the problem is that for code in the production process you cannot compile your LESS each time to test it against changes. It should be a hassle-free experience, like what I do when I directly code CSS. I have to write LESS, and immediately he should think about the pages.

So can someone help me set up such a workflow?

Any suggestions from other similar frameworks are welcome.

+6
source share
3 answers

I use Less-PHP in development: every time I update my browser for testing after changing the main .less , .css .

Then in the production process I only need to copy the .css file, as usual.

I will never use Less.js in production, because it will only work for users who have activated JS, will slow down each user for both load time and render time when it is not needed.

EDIT: There is also software that will wait for your LESS file to be modified and saved, and compile it when that happens. Again Less PHP can be configured once per project and will do the same, I don’t want to run the daemon on my system every day if I can avoid it. I already have a firewall, AV, MSN, Dropbox, jabber client, copypaste utility, built-in SVN, etc. EDIT in 2015: I used Prepros 4 for a while or instead used the grunt based compiler. My colleagues have a few bugs with Prepros 5, so I haven't installed it yet (Prepros 5 is now proprietary software, costs a few dollars. Very good investment imo)

EDIT2: It seems you are using Java. A small search query gives such a solution: http://www.asual.com/blog/lesscss/2009/11/05/less-for-java.html

+4
source

As you said, using less.js in production is a bad idea. To add another idea, if you use Git, you can generate production CSS files as part of the pre-commit hook, so you don't have to do anything manually for production. I wrote a little about the workflow that I use here: http://tjvantoll.com/2012/07/07/the-ideal-less-workflow-with-git/ .

+2
source

I also use Java, but for any technology, the following applies pretty much:

Development Mode :

  • Include fewer files but not include generated css files
  • Run less js

Products

  • Clean created css folder with ant
  • Use less rhino to compile css files with ant
  • Include generated css files but not include fewer files

I do a few additional things, such as themes / skins, which can be easily achieved with any build tool (ant, maven, ...). I also allow my system to ignore the version of the created folder, as it will be deleted and generated by the build process.

+1
source

Source: https://habr.com/ru/post/909895/


All Articles