[英]Maven plugin for versioning and minifying javascript
I have built a sophisticated ajax-driven single page webapp that uses a RESTful backend web service serving JSON. 我已经构建了一个复杂的ajax驱动的单页webapp,它使用一个服务于JSON的RESTful后端Web服务。 The javascript is split into many different files, each file representing some sort of feature or component.
javascript被分成许多不同的文件,每个文件代表某种特征或组件。
While the service has been in alpha testing, I've just be serving all these files separately without minification. 虽然该服务已经进行了alpha测试,但我只是在没有缩小的情况下单独提供所有这些文件。 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.
我想使用Maven将其添加到我的构建过程中。
I'm using the following "types" of javascript files, of which #3 and #4 are my concerns: 我正在使用以下“类型”的javascript文件,其中#3和#4是我关注的问题:
I'd like to do the following during my build process: 我想在构建过程中执行以下操作:
app-2.0.6.min.js
, where 2.0.6 is the maven project version. app-2.0.6.min.js
,其中2.0.6是maven项目版本。 feature-abc-56ab32de29.min.js
, where 56ab32de29 is the version number of that specific file. feature-abc-56ab32de29.min.js
,其中56ab32de29是该特定文件的版本号。 <script>
tags to point to javascript files with the correct version numbers. <script>
标记更新HTML文件以指向具有正确版本号的javascript文件。 Is there a maven plugin that will assist with the concatenation? 是否有maven插件可以协助连接?
Is there a maven plugin that will assist with the minification? 有没有maven插件可以帮助缩小? Ideally, I'd like to use Google Closure Compiler, but would work with others if simpler.
理想情况下,我想使用Google Closure Compiler,但如果更简单,可以与其他人合作。
Is there a maven plugin that will assist with the versioning? 是否有maven插件可以帮助进行版本控制?
Is there a way to have the type 4 javascript files have independent version numbers? 有没有办法让4型javascript文件具有独立的版本号? 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.
理想情况下,如果文件在版本2.0.5和2.0.6之间没有变化,则用户无需下载新版本,并且其缓存版本可以正常工作。 I'm using GIT for source control, so would there be a way to use a file's GIT hashcode for versioning?
我正在使用GIT进行源代码控制,那么有没有办法使用文件的GIT哈希码进行版本控制?
Is there a solution that will compress the javascript that is inline in regular HTML files without killing the HTML? 有没有一种解决方案可以压缩常规HTML文件中内联的javascript而不会破坏HTML?
Is there a solution that will compress and version my CSS files as well? 是否有压缩和版本化我的CSS文件的解决方案?
Take a look at the yuicompressor-maven-plugin . 看看yuicompressor-maven-plugin 。 It can aggregate various js (as well as css) files as well as minify and obfuscate them.
它可以聚合各种js(以及css)文件以及缩小和混淆它们。
这是一个全新的Maven插件,针对这项任务: http : //mojo.codehaus.org/webminifier-maven-plugin/
I've successfully incorporated RequireJS optimization (uses Google Closure compiler + does concatenation) in a Maven environment (for single page JS app). 我在Maven环境中成功地整合了RequireJS优化(使用Google Closure编译器+进行连接)(对于单页JS应用程序)。 See my question and the follow up answer for details: RequireJS Compilation in Maven project with external JS dependencies
有关详细信息,请参阅我的问题和后续答案: Maven项目中的RequireJS编译与外部JS依赖项
You could probably expand on that to version and archive the minified JS artifacts. 您可以将其扩展到版本并归档缩小的JS工件。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.