Maven插件的版本控制和缩小JavaScript [英] Maven plugin for versioning and minifying javascript

查看:172
本文介绍了Maven插件的版本控制和缩小JavaScript的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经建立了一个使用JSON提供一个RESTful后端Web服务的复杂的Ajax驱动的单页Web应用程序。 JavaScript的被分为许多不同的文件,每个文件重新presenting某种功能或组件的。

I have built a sophisticated ajax-driven single page webapp that uses a RESTful backend web service serving JSON. The javascript is split into many different files, each file representing some sort of feature or component.

虽然服务已经在字母的测试,我只是单独提供所有这些文件没有缩小。但现在,我想推出的测试版的版本,我真的需要合并文件,它们最小化和版本他们。我想这添加到我的生成过程中,使用Maven。

While the service has been in alpha testing, I've just be serving all these files separately without minification. But now that I'd like to launch a beta version, I really need to combine files, minify them, and version them. I want to add this to my build process, using Maven.

我使用的JavaScript文件下面的类型,其中#3,#4是我的顾虑:

I'm using the following "types" of javascript files, of which #3 and #4 are my concerns:


  1. 外部文件,例如一个jQuery和jQuery的用户界面从谷歌CDN服务。很少改变这些版本中,可以手动操作。

  2. jQuery插件是我自己主持,如fullcalendar或UI布局。再次,我很少更新这些新的版本,并可以手动处理它。

  3. 广泛应用的JavaScript code。自定义JavaScript是跨多个文件小号$ P $垫偶尔会发生变化。所有这些文件需要加载的应用程序工作。

  4. 针对功能的JavaScript code。即当请求特定的功能需求加载自定义JavaScript。这code可能频繁变动,并在启动时没有加载。

我想在我的构建过程中做到以下几点:

Build Objectives

I'd like to do the following during my build process:


  • 串连所有3类JavaScript文件一起,它们最小化,并保存为一个版本号的单个文件。例如: APP-2.0.6.min.js ,其中2.0.6是Maven项目版本

  • 所有4类型的文件应单独精缩并保存为名称中的版本号单独的文件。例如:功能-ABC-56ab32de29.min.js ,其中56ab32de29是特定文件的版本号

  • 更新HTML文件,<脚本方式> 标签指向了正确的版本号的JavaScript文件

  • 更新Javscript文件4负载类型功能的JavaScript文件指向正确的版本。

  • Concatenate all type 3 javascript files together, minify them, and save as a single file with a version number. For instance: app-2.0.6.min.js, where 2.0.6 is the maven project version.
  • All type 4 files should be individually minified and saved as separate files with version numbers in the name. For instance: feature-abc-56ab32de29.min.js, where 56ab32de29 is the version number of that specific file.
  • Update HTML files with <script> tags to point to javascript files with the correct version numbers.
  • Update Javscript files that load type 4 feature javascript files to point to the right versions.

  • 有一个Maven插件,将协助串联?

  • Is there a maven plugin that will assist with the concatenation?

有一个Maven插件,将协助缩小?理想情况下,我想使用谷歌关闭编译器,但如果简单将与他人合作。

Is there a maven plugin that will assist with the minification? Ideally, I'd like to use Google Closure Compiler, but would work with others if simpler.

有一个Maven插件,将协助版本?

Is there a maven plugin that will assist with the versioning?

有没有办法有4类JavaScript文件都有独立的版本号?理想情况下,如果一个文件不2.0.5版本和2.0.6之间的变化,没有必要为用户下载新版本和缓存的版本将正常工作。我使用源代码控制GIT,所以会有使用文件的哈希GIT code版本控制的方式?

Is there a way to have the type 4 javascript files have independent version numbers? Ideally, if a file doesn't change between version 2.0.5 and 2.0.6, there is no need for users to download a new version and their cached version would work fine. I'm using GIT for source control, so would there be a way to use a file's GIT hashcode for versioning?

有一个解决方案,COM preSS是内嵌在常规的HTML文件,而不杀死HTML的JavaScript?

Is there a solution that will compress the javascript that is inline in regular HTML files without killing the HTML?

有一个解决方案,COM preSS和我的版本的CSS文件中呢?

Is there a solution that will compress and version my CSS files as well?

推荐答案

看看的<一个href=\"http://alchim.sourceforge.net/yuicom$p$pssor-maven-plugin/index.html\">yuicom$p$pssor-maven-plugin.它可以聚合各种JS(以及CSS)文件以及压缩和模糊处理它们。

Take a look at the yuicompressor-maven-plugin. It can aggregate various js (as well as css) files as well as minify and obfuscate them.

这篇关于Maven插件的版本控制和缩小JavaScript的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆