I want to use a less compiler like dotless as eclipse builder. If I set the build option "Run the builder:" to "During auto builds", every 5-10 sec the builder is runing (thats ok) but it also ask me to save, instead of ignoring the unsaved files.
As workaround I activate the workspace-option "Save automatically before build" and bind Ctrl+S to "build all"
Is there a better solution?
To automatically transpile LESS to CSS in Eclipse, I explain two possible ways.
(I edited this post after I wrote the plugin, so the manual way is the old way, that the original post contained over some time, which you may have seen here a while ago)
For either solution you need to install node and lessc (the less-compiler).
Installing lessc through npm with the following commands:
npm install -g less-compiler
npm install -g less
I wrote an eclipse plugin to handle transpiling in eclipse. Just install it and follow the instructions on the project readme to configure transpiling for your project.
-> https://github.com/gossi/eclipse-transpiler-plugin
I wrote myself a little shell script that runs lessc after every save on a .less file. However, eclipse keeps its own environment, thus no %PATH variables are available in eclipse. So, you need the full path to the lessc command, which you can find with which lessc:
$ which lessc
/usr/local/bin/lessc
Also, because lessc runs on a node environment:
$ head -n1 /usr/local/bin/lessc
#!/usr/bin/env node
You cannot run this directly, because eclipse doesn't know about your environment. You need to prepend the node command, to achieve a lessc call in eclipse:
$ which node
/usr/local/bin/node
The shell script with the full path to lessc is:
#!/bin/bash
/usr/local/bin/node /usr/local/bin/lessc css/*.less > css/*.css
You may adjust the input and output sources according to your project. In order to make that run in eclipse we need to make it run as a builder. Here you go:
Now, open a .less file, do some changes and save. Open the compiled .css file - tada :)
Windows:
I think this will work on windows too, with an according .bat file.
Have fun
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With