Aipoでjsを圧縮して1ファイルに纏める方法

@iwasaki 324views 更新:2014年2月7日

https://github.com/aipocom/aipo/blob/master/war/pom.xml

に書いてあるのですが、複数のJavascriptを以下のように設定して1つのJavascriptにしています。

            <aggregation>
              <insertNewLine>true</insertNewLine>
              <output>target/aipo/javascript/aipo/common.js</output>
              <includes>
                <include>../../../../target/aipo/javascript/aipo/customize/form.js</include>
                <include>../../../../target/aipo/javascript/aipo/fileupload/form.js</include>
                <include>../../../../target/aipo/javascript/aipo/schedule/form.js</include>
                <include>../../../../target/aipo/javascript/aipo/todo/form.js</include>
                <include>../../../../target/aipo/javascript/aipo/workflow/form.js</include>
                <include>../../../../target/aipo/javascript/aipo/blog/form.js</include>
                <include>../../../../target/aipo/javascript/aipo/msgboard/form.js</include>
                <include>../../../../target/aipo/javascript/aipo/note/form.js</include>
                <include>../../../../target/aipo/javascript/aipo/exttimecard/form.js</include>
                <include>../../../../target/aipo/javascript/aipo/report/form.js</include>
                <include>../../../../target/aipo/javascript/aipo/activity/form.js</include>
                <include>../../../../target/aipo/javascript/aipo/account_user/form.js</include>
                <include>../../../../target/aipo/javascript/aipo/account_person/form.js</include>
                <include>../../../../target/aipo/javascript/aipo/gadgets_admin/form.js</include>
                <include>../../../../target/aipo/javascript/aipo/timeline/form.js</include>
                <include>../../../../target/aipo/javascript/aipo/page/form.js</include>
                <include>../../../../target/aipo/javascript/aipo/tutorial/tutorial.js</include>
                <include>../../../../target/aipo/javascript/aipo/calendar/weekly.js</include>
                <include>../../../../target/aipo/javascript/aipo/mygroup/form.js</include>
                <include>../../../../target/aipo/javascript/aipo/gpdb/form.js</include>
                <include>../../../../target/aipo/javascript/aipo/fileuploadadv/form.js</include>
              </includes>
            </aggregation>

で複数のJavascriptを1つにまとめています。転送量を減らして高速化するためには必要な対策ですね。

 

ちなみに同様にCSSも1つに圧縮しています。

            <aggregation>
              <insertNewLine>true</insertNewLine>
              <output>target/aipo/themes/default/css/aui-all.css</output>
              <includes>
                <include>extend.css</include>
                <include>common.css</include>
                <include>aui.css</include>
             </includes>
            </aggregation>

圧縮にはyuicompressor-maven-pluginを使用しています。

ログイン / 新規登録してコメントする

このソースコードをストックして後で利用したり、作業に利用したソースコードをまとめることができます。

こちらもお役に立つかもしれません