Results 1 to 7 of 7

Thread: How to strip all comments from the testing build?

  1. #1
    Sencha Premium Member robert_k's Avatar
    Join Date
    Jun 2012
    Posts
    35
    Vote Rating
    2
      0  

    Default How to strip all comments from the testing build?

    I noticed that my testing build app.js file is 1.9Mb, and in the interest of saving bandwidth and loading time I want to strip comments during the build process. I know I can do this with uglifyjs, but how would I integrate this as part of the compilation process?

  2. #2
    Sencha - Sr Software Engineer mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    39,339
    Vote Rating
    1297
      0  

    Default

    You can create a plugin to hook into the build process
    Mitchell Simoens @LikelyMitch
    Sencha Inc, Senior Software Engineer
    ________________
    Learn BBCode and use it!

    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 Premium Member robert_k's Avatar
    Join Date
    Jun 2012
    Posts
    35
    Vote Rating
    2
      0  

    Default

    Mitchell, that much is obvious. What isn't obvious is how to actually accomplish what I'm after. I've never used Ant in my life, and find Sencha Cmd to be undocumented (and therefore hard to extend).

  4. #4
    Sencha - Ext JS Dev Team dongryphon's Avatar
    Join Date
    Jul 2009
    Location
    Kansas
    Posts
    1,694
    Vote Rating
    232
      0  

    Default

    You didn't mention which framework you are using and there are some differences in the details there, but maybe something like this in your app's build.xml would work:

    Code:
        <target name="-after-build">
            <x-strip-js srcfile="${build.page.file}" outfile="${build.page.file}"/>
        </target>
    To see the properties in use (and hence things you can control) check out .sencha/app/build-impl.xml.

    The "-after-build" target is called on the end of "sencha app build" so you can fine tune the results there as needed.

    See also http://docs-devel.sencha.com/ext-js/...de/command_ant

    For general Ant tasks, see http://ant.apache.org/manual/index.html

    If this needs to be only done in testing builds (since x-strip-js may not like the compressed output), you can do this:

    Code:
        <target name="-after-build">
            <if>
                <equals arg1="${args.environment}" arg2="testing"/>
                <then>
                    <x-strip-js srcfile="${build.page.file}" outfile="${build.page.file}"/>
                </then>
            </if>
        </target>
    Don Griffin
    Director of Engineering - Frameworks (Ext JS / Sencha Touch)

    Check the docs. Learn how to (properly) report a framework issue and a Sencha Cmd issue

    "Use the source, Luke!"

  5. #5
    Sencha Premium Member robert_k's Avatar
    Join Date
    Jun 2012
    Posts
    35
    Vote Rating
    2
      0  

    Default

    You're right, I did forget to mention that I'm using Sencha Touch 2.1.1 with Sencha Cmd 3.0.2.288.

    The code you gave throws an error in ST2.1.1/Cmd3.0.2:

    Code:
    [ERR]        BUILD FAILED
    [ERR]        java.lang.RuntimeException: $'{'build.page.file'}' (No such file or directory)
    I switched the definition to:

    Code:
        <target name="-after-build">
            <if>
                <equals arg1="${args.environment}" arg2="testing"/>
                <then>
                    <x-strip-js srcfile="${build.dir}/testing/app.js" outfile="${build.dir}/testing/app.js"/>
                </then>
            </if>
        </target>
    I edited because I found a solution. Seems like just listing the source/output as "app.js" won't tell Ant where to find the file.
    Last edited by robert_k; 22 Mar 2013 at 5:59 AM. Reason: Found a working solution...

  6. #6
    Sencha - Ext JS Dev Team dongryphon's Avatar
    Join Date
    Jul 2009
    Location
    Kansas
    Posts
    1,694
    Vote Rating
    232
      0  

    Default

    I think I missed some properties on x-strip-js sorry. Try this:

    Code:
       <x-strip-js srcfile="${build.dir}/testing/app.js"
            outfile="${build.dir}/testing/app.js"
            blockcomments="true"
            linecomments="true"
            keepfirstcomment="true"/>
    You can adjust those three attributes to suite your needs.
    Don Griffin
    Director of Engineering - Frameworks (Ext JS / Sencha Touch)

    Check the docs. Learn how to (properly) report a framework issue and a Sencha Cmd issue

    "Use the source, Luke!"

  7. #7
    Sencha Premium User SebTardif's Avatar
    Join Date
    Feb 2011
    Location
    Cambridge, MA
    Posts
    1,039
    Vote Rating
    94
      0  

    Default

    Quote Originally Posted by dongryphon View Post
    You can adjust those three attributes to suite your needs.
    Do we have a better way with the latest Sencha Cmd and latest Ext JS 5? What you give is XML, but it seems I should be modifying testing.properties to specify the kind of build I want.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •