1. #1
    Sencha User
    Join Date
    Feb 2009
    Location
    Glasgow, Scotland
    Posts
    281
    Vote Rating
    1
    Stoot98 will become famous soon enough

      0  

    Default Include extra scripts in Ext JS build

    Include extra scripts in Ext JS build


    Hi

    I'm trying to use Sencha Cmd to build an Ext JS 4.1.1a application that uses a third party script (non-Ext) which I have included in the index.html - all works well in this dev environment.

    However, when I try to build with Sencha Cmd 3.0.2.288 I need a way to include these extra scripts in the process so they are copied to the output directory.

    In a Sencha Touch app you would include these in the app.json file but I'm not sure what the equivalent is for Ext JS?

    The "built" index.html includes the references to the files but they are not copied over.

    Any pointers would be appreciated!

    Cheers
    Stuart

  2. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    36,522
    Vote Rating
    814
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      1  

    Default


    This is simple to do; all that's needed is to choose the appropriate target in build.xml. For this example, we'll hook into the -after-page build target to minify the 3rd-party script. Place the following into your project root node in build.xml:

    Code:
    <property name="common.dir" location="common"/>
    
    <target name="-after-page">
        <x-sencha-command>
            fs
            minify
                --from=${common.dir}/in.js
                --to=${common.dir}/out.js
                --compressor=closurecompiler
        </x-sencha-command>
    </target>
    Note that it's also possible to define the common.dir property in the ./.sencha/app/sencha.cfg file:

    Code:
    app.name=MyApp
    app.framework=ext
    app.classpath=${app.dir}/app
    
    common.dir=common
    
    app.cmd.version=3.0.2.288
    And here we'll combine the two operations into one:

    Code:
    <target name="-after-page">
        <x-sencha-command>
            fs
            minify
                --from=${common.dir}/in.js
                --to=${common.dir}/out.js
                --compressor=closurecompiler
            and
            concatenate
                --from=${build.dir}/all-classes.js,${common.dir}/out.js
                --to=${build.dir}/final-build.js
        </x-sencha-command>
    </target>
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

  3. #3
    Sencha User mono blaine's Avatar
    Join Date
    Jul 2008
    Location
    Turkey
    Posts
    123
    Vote Rating
    8
    mono blaine will become famous soon enough

      0  

    Default


    Is there any way to overwrite or delete a previously concatenated file just before the "fs concatenate" command is executed? An additional argument, maybe? Docs won't help.

  4. #4
    Sencha User mono blaine's Avatar
    Join Date
    Jul 2008
    Location
    Turkey
    Posts
    123
    Vote Rating
    8
    mono blaine will become famous soon enough

      0  

    Default


    OK, found it. We could just use ant stuff within <target name="-after-page">:

    Code:
    <delete file="${path.to.some.file}"/>

  5. #5
    Sencha User
    Join Date
    Feb 2009
    Location
    Glasgow, Scotland
    Posts
    281
    Vote Rating
    1
    Stoot98 will become famous soon enough

      0  

    Default


    Thanks for the reply Mitchell, that got things sorted.

    Cheers
    Stuart