Results 1 to 4 of 4

Thread: Special build for login page

  1. #1
    Sencha User
    Join Date
    Apr 2010
    Posts
    85

    Default Special build for login page

    ExtJS 4.2.1
    Sencha CMD 4.0.0.126

    I know I could achieve this with custom sencha compile (http://docs.sencha.com/extjs/4.2.1/#...mand_app_multi), but is there a way to build two separate .js files, one for app and one for login, based on app.js or app-login.js?

    I have the following structure (files in gray)
    Code:
    AppName
        app
            controller
            model
            store
            view
            Application.js (requires all controllers except login, all stores, ...)
            ApplicationLogin.js (requires only login controller and view, no stores)
        build
        data
        overrides
        packages
        resources
        sass
        app-login.js (extends ApplicationLogin.js)
        app.js (extends Application.js)
        app.json
        bootstrap.css
        bootstrap.js
        build.xml
        index.html
        login.html
    
    What I want after sencha app build production

    Code:
    AppName
        build
            production
                AppName
                    AppName-app.js
                    AppName-login.js (with minimal possible code)
    So I want to hook into -after-build (or somewhere better) and compile AppName-login.js with just the code required for login to work. How can I achieve that?

    BTW: I use Symfony2 so I don't actually need index.html and login.html in the app folder, because I use a custom index.html.twig that loads appropriate version depending on dev/prod Symfony environment ... index.html is there just so that sencha app build works.

  2. #2
    Sencha User slemmon's Avatar
    Join Date
    Mar 2009
    Location
    Boise, ID
    Posts
    6,165

    Default

    The only way I can think to do that is with custom statements using sencha compile where you exclude all classes from the build and then just include the classes and their dependencies necessary for the given app sans login and login sans app builds.

  3. #3
    Sencha User
    Join Date
    Apr 2010
    Posts
    85

    Default

    For anyone with the same problem ... I managed to solve it by running a custom sencha compile command at the end of sencha app build. I hook into -after-build like this in application build.xml

    Code:
    <?xml version="1.0" encoding="utf-8"?><project name="PBO" default=".help">
        <!--
        The build-impl.xml file imported here contains the guts of the build process. It is
        a great idea to read that file to understand how the process works, but it is best to
        limit your changes to this file.
        -->
        <import file="${basedir}/.sencha/app/build-impl.xml"/>
    
    
        <target name="-after-build">
            <echo>Create APP-login.js</echo>
            <x-sencha-command>
                compile
                    --classpath=ext/src,app-login.js,app,overrides
                    page
                        --yui
                        --cla=APP-login.js
                        --in=${app.dir}/login.html
                        --out=${build.dir}/login.html
            </x-sencha-command>
        </target>
        
    </project>
    This works.

    I have one more problem though. Even though I followed this guide http://docs.sencha.com/extjs/4.2.2/#...e/command_code, the filesize of APP-login.js is still 800kb, which is really big for an app that only requires Ext.window.Window, Ext.form.Panel and Ext.direct.RemotingProvider. I still need to thoroughly analyze non-compressed version, but any ideas on how to slim down the filesize?

    I guess I could separate ext and app classes, using ext sources on both login and app page. This way browser would cache ext sources and load app faster. I would end up with something like this:
    APP-ext.js (all required ext sources for login and for app)
    APP-login.js (just app login sources)
    APP-app.js (just app sources, without login)

    What do you think?

  4. #4
    Sencha User slemmon's Avatar
    Join Date
    Mar 2009
    Location
    Boise, ID
    Posts
    6,165

    Default

    I'm afraid that's about right with the framework's current dependency tree. You could split out the Ext and App classes to separate files for further caching is about all you can do.

Posting Permissions

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