We don’t allow questions seeking recommendations for software libraries, tutorials, tools, books, or other off-site resources. You can edit the question so it can be answered with facts and citations.
Closed 7 months ago.
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
发布评论
评论(4)
我最近使用类似的技术 LessCss 走了同样的路。起初,我尝试将 JRuby 嵌入到我的构建生命周期中。但不幸的是 Maven + JRuby 是一个怪物,它缓慢、巨大且有缺陷(有一半的时间它甚至无法启动,因为它会抱怨它正在运行的文件路径)。
幸运的是,现在有 LessCss 的 JavaScript 端口,我现在通过 Mozilla Rhino 嵌入它。我 在这篇博文中描述该过程。
昨天,我把它提升到了一个新的水平,制作了一个 Maven LessCss 插件来最大限度地减少 POM 配置和代码重复。不幸的是,我无法分享它,因为它是我当前客户的专有代码,但解决方案很简单:
使用 GMaven 创建插件,创建一个调用 LessCss 编译器的抽象基础 mojo 以及为不同资源集配置基础 mojo 的几个具体实现:
例如
lesscss:compile
从所有编译
<资源>
到${project.build.outputDirectory}
lesscss:test-compile
编译自
所有
到${project.build.testOutputDirectory}
lesscss:war-compile
(从
所有
src/main/webapp
到${project.build.directory}/${project.build.finalName}
,爆炸的战争目录)
所以虽然我无法帮助你使用SASS(除了你询问授权
或者将其移植到 Groovy、Java 或 JavaScript),我想我已经向您展示了一个可行的替代方案。
当然,您也可以在没有 Groovy 的情况下在 java 中实现 Maven 插件(也可以通过 Rhino 嵌入 JavaScript),但我认为在 Groovy 中更容易。
I went down the same road recently using LessCss, a similar technology. At first I tried to embed JRuby in my build lifecycle. But unfortunately Maven + JRuby is a monster, it's slow, huge and buggy (half the time it wouldn't even start because it would complain about the file path it was running on).
Fortunately, there is now a JavaScript port of LessCss, which I now embed via Mozilla Rhino. I describe the process in this blog post.
Yesterday though I took it to the next level, making a Maven LessCss Plugin to minimize POM configuration and code duplication. Unfortunately I can't share it because it's proprietary code for my current client, but the solution is simple:
Use GMaven to create the Plugin, create an abstract base mojo that calls the LessCss compiler and several concrete implementations that configure the base mojo for different resource sets:
e.g.
lesscss:compile
compiles from all
<resources>
to${project.build.outputDirectory}
lesscss:test-compile
compiles from
all
<testResources>
to${project.build.testOutputDirectory}
lesscss:war-compile
(compiles from
all
src/main/webapp
to${project.build.directory}/${project.build.finalName}
, the exploded war directory)
So while I can't help you with SASS (apart from you asking the auth
or to port it to Groovy, Java or JavaScript), I think I've shown you a feasible alternative.
Of course you can also implement a Maven Plugin in java without Groovy (also embedding the JavaScript via Rhino), but I think it's easier in Groovy.
我最终使用了 wro4j。
强烈推荐这个库,因为它可以处理很多事情,比如 less css 和咖啡 CoffeeScript。
I ended up using wro4j.
Highly recommend the library as it will handle many things like less css and coffee CoffeeScript.
this 问题回答了在 eclipse 中使用 sass 的一个很好的解决方案。
A good solution for using sass with eclipse is answered in this question.
Sass 命令行界面非常全面。如果您在构建规则中调用
sass --update
,则可以仅使用标准 Sass 可执行文件(通过 Ruby 或 JRuby),而无需将其直接集成到您的构建中。The Sass command-line interface is very thorough. If you call out to
sass --update
in your build rules, you can just use the standard Sass executable (either via Ruby or JRuby) without having to integrate it directly into your build.