eclipse pdt 中不明显的 lesscss 编译器
我想使用像 dotless 这样的 less 编译器作为 eclipse 构建器。如果我将构建选项“运行构建器:”设置为“自动构建期间”,则构建器每 5-10 秒运行一次(没问题),但它也会要求我保存,而不是忽略未保存的文件。
作为解决方法,我激活工作区选项“构建前自动保存”并将 Ctrl+S 绑定到“构建全部”
是否有更好的解决方案?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
为了在 Eclipse 中自动将 LESS 转换为 CSS,我解释了两种可能的方法。
(我在编写插件后编辑了这篇文章,因此手动方式是旧方式,原始帖子包含了一段时间,您可能已经在这里看到了不久前)
要求
对于任一解决方案,您都需要安装
node
和lessc
(less 编译器)。使用以下命令通过
npm
安装lessc
:1. 安装 Eclipse Transpiler 插件
我编写了一个 Eclipse 插件来处理 Eclipse 中的转译。只需安装它并按照项目自述文件中的说明为您的项目配置转译即可。
-> https://github.com/gossi/eclipse-transpiler-plugin
2. 手动安装构建器
我自己编写了一个小 shell 脚本,每次保存 .less 文件后都会运行
lessc
。但是,Eclipse 保留自己的环境,因此 Eclipse 中没有可用的%PATH
变量。因此,您需要lessc
命令的完整路径,可以使用which lessc
找到它:另外,因为
lessc
在节点环境上运行:你不能直接运行它,因为 eclipse 不知道你的环境。您需要预先添加节点命令,以在 Eclipse 中实现
lessc
调用:具有
lessc
的完整路径的 shell 脚本是:您可以根据您的项目调整输入和输出源。为了使其在 Eclipse 中运行,我们需要使其作为构建器运行。在这里:
现在,打开一个 .less 文件,进行一些更改并保存。打开编译后的 .css 文件 - tada :)
Windows:
我认为这也适用于 Windows,带有相应的 .bat 文件。
玩得开心
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
node
andlessc
(the less-compiler).Installing
lessc
throughnpm
with 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
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 thelessc
command, which you can find withwhich lessc
:Also, because
lessc
runs 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
lessc
call in eclipse:The shell script with the full path to
lessc
is: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
您可以使用工具来查看 LESS 文件并在更改时进行编译:
You could use a tool to watch your LESS files and compile on change: