• RequireJS optimizer Ant task


    build.xml文件

     1 <?xml version="1.0" encoding="utf-8"?>
     2 <project name="sample-require-js" default="" basedir=".">
     3     
     4     <!-- properties -->
     5     
     6     <property name="r.js" value="_build/rjs/r.js" />
     7     <property name="closure.jar" value="_build/closure/compiler.jar" />
     8     <property name="rhino.jar" value="_build/rhino/js.jar" />
     9     <property name="js.build" value="_build/js.build.js" />
    10     <property name="css.build" value="_build/css.build.js" />
    11     
    12     <!-- custom tasks -->
    13     
    14     
    15     <!-- targets -->
    16     
    17     <target name="-optimize" description="Combine and minify files.">
    18         <java classname="org.mozilla.javascript.tools.shell.Main">
    19             <classpath>
    20                 <pathelement location="${rhino.jar}" />
    21                 <pathelement location="${closure.jar}" />
    22             </classpath>
    23             <arg value="${r.js}"/>
    24             <arg value="-o"/>
    25             <arg value="${requirejs.optimizer.settings}"/>
    26         </java>
    27         <echo message="optimized ${requirejs.optimizer.settings}" />
    28     </target>
    29     
    30     <target name="optimizeJS">
    31         <echo message="Combining and minifying JS files." />
    32         <antcall target="-optimize">
    33             <param name="requirejs.optimizer.settings" value="${js.build}" />
    34         </antcall>  
    35     </target>
    36     
    37     <target name="optimizeCSS">
    38         <echo message="Combining and compressing CSS files." />
    39         <antcall target="-optimize">
    40             <param name="requirejs.optimizer.settings" value="${css.build}" />
    41         </antcall>  
    42     </target>
    43     
    44 </project>

    css.build.js

    1 ({
    2     baseUrl: "../style",
    3     optimizeCss : "standard",
    4     dir: "../deploy/style"
    5 })

    js.build.js

     1 ({
     2     baseUrl: "../scripts",
     3     dir: "../deploy/scripts",
     4     modules: [
     5         {
     6             name: "main",
     7             include : [
     8                 "lib/my_awesome_shared_lib"
     9             ]
    10         },
    11         {
    12             name : "sections/home/main",
    13             exclude : [
    14                 "lib/my_awesome_shared_lib"
    15             ]
    16         },
    17         {
    18             name : "sections/gallery/main",
    19             exclude : [
    20                 "lib/my_awesome_shared_lib"
    21             ]
    22         }
    23     ]
    24 })

    js.build.js

     1 ({
     2     baseUrl: "/app",
     3     name: "main",
     4     optimize: 'closure',
     5     out: "main-built.js",
     6     paths: {
     7         underscore:   '/libs/underscore/underscore-1.4.1.amd.min',
     8         backbone:     '/libs/backbone/backbone-0.9.2.amd',
     9         validation :  '/libs/backbone/backbone-validation-amd',
    10         jquery:       'empty:',
    11     },
    12     shim: {
    13         'underscore':   {exports: '_'},
    14         'backbone':     {deps: ['underscore'],exports: 'Backbone'}
    15     }
    16 })

     

     

     

  • 相关阅读:
    source命令
    bash中单引号与双引号的总结
    鸟哥的linux私房菜学习笔记3
    鸟哥的linux私房菜学习笔记2
    /usr/sbin/atd 和 /etc/init.d/atd有什么区别
    Linux中/etc/fstab /etc/mtab /proc/mounts这三个文件的分析与比较
    服务器本机不能登陆的解决
    有用的博客
    推荐几个好用的PHP集成开发环境
    ANDROID开发笔记(二)
  • 原文地址:https://www.cnblogs.com/terrylin/p/2784331.html
Copyright © 2020-2023  润新知