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)
Requirements
For either solution you need to install
nodeandlessc(the less-compiler).Installing
lesscthroughnpmwith the following commands:1. Install the Eclipse Transpiler Plugin
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
2. Manually install a builder
I wrote myself a little shell script that runs
lesscafter every save on a .less file. However, eclipse keeps its own environment, thus no%PATHvariables are available in eclipse. So, you need the full path to thelessccommand, which you can find withwhich lessc:Also, because
lesscruns on a node environment:You cannot run this directly, because eclipse doesn’t know about your environment. You need to prepend the node command, to achieve a
lessccall in eclipse:The shell script with the full path to
lesscis: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