将 JS 缩小作为 Maven 目标运行?
我正在尝试在 Maven 目标中使用 YUI 压缩器,但我对 Maven 的内部工作方式还很陌生。我看到我可以使用以下命令将所有 js 复制到新目录:
<copy todir="blah">
<fileset>
<!-- A bunch of file extension types -->
</fileset>
</copy>
现在,对于每个 css 和 js 文件,我想运行 yui 压缩器并将文件输出到上面复制的文件的最终位置。上面给出的副本中并未维护目录结构,因此在创建 Maven 目标时可能需要考虑这一点。
我从哪里开始?我基本上需要
java -jar yuicompressor input.js -o output.js
在所有文件上运行。我仅限于 maven 1.x,那么我从哪里开始呢?我想让这成为一个 Maven 目标,以避免在构建之前必须手动压缩 js,因为那样会很草率。如果我可以执行外部 python/perl 脚本来执行此操作,那也很好,但我认为也许有更好的方法来执行此操作。
I'm trying to use YUI compressor in a maven goal, but I'm pretty new to the inner workings of maven. I see that I can copy all js to a new directory with the following:
<copy todir="blah">
<fileset>
<!-- A bunch of file extension types -->
</fileset>
</copy>
Now, for each css and js file, I want to run the run the yui compressor and output the file to the final locations of the files copied above. Not that directory structure is maintained in the copy given above, so that may be something to consider when creating the maven goal.
Where do I start? I essentially need to run
java -jar yuicompressor input.js -o output.js
on all files. I'm restricted to maven 1.x, so where do I start? I want to make this a maven goal to avoid having to compress js by hand before a build, as that would be sloppy. If I could execute an external python/perl script to do this, that would be fine also, but I think that there is perhaps a better maveny way to do this.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用 YUI 压缩器 ant 任务并按照教程进行操作。
YUI ant 任务。
Use YUI compressor ant task and follow the tutorial.
YUI ant task.