开发者

Compress and merge multiple JS files using Shrinksafe

开发者 https://www.devze.com 2023-02-19 10:48 出处:网络
I need to compress and merge multiple JavaScript files (in a particular folder) to a single file using Shrinksafe. I\'m able to merge the files to a single one using the below command.

I need to compress and merge multiple JavaScript files (in a particular folder) to a single file using Shrinksafe. I'm able to merge the files to a single one using the below command.

java -jar shrinksafe.jar  *.js  >  testMin.js

The problem with this is that, it does not put all the script in a single line. It just removes the comments.

Also I need to achieve the same task using ant build script.

I tried the below approach

<target name="compress-js">
    <echo message="Starting JS compress Build"/>            
    <java fork="true" dir="${shrinksafe.util.path}/buildscripts" classname="org.mozilla.javascript.tools.shell.Main">
         <arg value="build.js"/>
         <arg line="releaseDir=../../../../../../StaticFiles/acb profile=acb_js action=clean,release *.js > acb.js" />
         <c开发者_StackOverflowlasspath>
           <pathelement location="${shrinksafe.util.path}/shrinksafe/js.jar"/>
           <pathelement location="${shrinksafe.util.path}/shrinksafe/shrinksafe.jar"/>
           <pathelement path="${java.class.path}"/>
         </classpath>
   </java>
   <echo message="js build successfull." />
</target>

I'm not sure if I can achieve my requirement using the above script. The is the dojo profile that I'm using.

//Below code is from acb-js.profile.js file.
    dependencies = {
            layers: [      
                {
                    name: "../gp-js.js",
                    resourceName:"gp-js",
                    dependencies: [
                    ]
                }
            ],
            prefixes: [
              ["scripts", "../../scripts"]
            ]
    };

My JavaScript files are inside StaticFiles/acb/homepage folder.

Please help me.Thanks in advance. Any help will be greatly appreciated.


Have you tried the online facility for ShrinkSafe Here? I haven't used the jar or ant to do that, so I don't know how if that will work!

0

精彩评论

暂无评论...
验证码 换一张
取 消