1. #1
    Sencha User
    Join Date
    Mar 2009
    Location
    Reading, UK
    Posts
    33
    Vote Rating
    1
    Curtis Fletcher is on a distinguished road

      0  

    Default Compile process grabbing files that are unrelated

    Compile process grabbing files that are unrelated


    I have a multi-page MVC ext-js 4.12a application that was not built using sencha Cmd, I'm now trying to alter the application so that is it capable of compilation under sencha Cmd ( v3.0.0.190)

    The app is multi-page with many of the classed being shared between the pages, I was intending to use intersect to generate common bundles but that is currently not working so I'm simply trying to compile a single bundle for the main page as a starting point.

    My directory structure is thus:
    Code:
    root
    	page1.html
    	page2.html
    	page3.html
    	app
    		controller
    		model
    		util
    		view
    		page1.js
    		page2.js
    		page3.js
    		overrides.js
    		lang.js
    Each pageX.html looks like this:
    Code:
    <!DOCTYPE HTML>
    <html>
    <head>
        <meta charset="UTF-8">
        <title>XXXX</title>
        <link rel="stylesheet" href="resources/css/default/app.css">
        <!-- <x-compile> -->
            <!-- <x-bootstrap> -->
                <script src="ext/ext-debug.js"></script>
                <script src="bootstrap.js"></script>
            <!-- </x-bootstrap> -->
            <script src="app/overrides.js"></script>
            <script src="app/pageX.js"></script>
        <!-- </x-compile> -->
    </head>
    <body></body>
    </html>
    pageX.js is the application start-up code, depending on the page, sometimes this is an actual Ext.application sometimes it's just a bare viewport. However during compilation I see that sencha Cmd parses and includes _all_ of the pageX.js files for no reason I can determine. My stripped down plugin.xml looks like this:
    Code:
    <project basedir=".">
    	<import file="${workspace.config.dir}/plugin.xml"/>
    	<target name="app-build-impl">
    		<local name="build.dir"/>
    		<property name="build.dir" location="${workspace.build.dir}"/>
    		<x-sencha-command>
    			compile
    			page
    				-name=page1
    				-in=page1.html
    				-out=${build.dir}/page1.html
    			and
    			concat
    				${build.dir}/js/page1.js
    		</x-sencha-command>
    	</target>
    </project>
    page1[.html/.js] in _no way_ refers to page2.js (or page3.js etc) and yet they get included in the build/js/page1.js bundle. Why does sencha Cmd even look at that file, is there any way to determine why it's reading that file at all?

  2. #2
    Sencha - Ext JS Dev Team dongryphon's Avatar
    Join Date
    Jul 2009
    Posts
    1,295
    Vote Rating
    121
    dongryphon is a name known to all dongryphon is a name known to all dongryphon is a name known to all dongryphon is a name known to all dongryphon is a name known to all dongryphon is a name known to all

      0  

    Default


    By the looks of it, you appear to have some scaffolding in place (perhaps in a ".sencha" folder) but your post does not mention where plugin.xml is located. The snippet makes me think you are editing ".sencha/app/plugin.xml".

    So a couple things here.

    First is the use of plugin.xml. The role of plugin.xml in apps and workspaces is to provide before/after hooks for various commands. The "app-build-impl" target is intended for the framework (Ext JS or Sencha Touch) to provide the exact meaning of "sencha app build" and should probably not be replaced.

    The ideal location for application build processes would be a build.xml file, which is what Cmd would generate.

    Second, and more directly to your question, your compile command has an oops around the use of the current set. At the time your concat command executes, the current set is "all files". This is the default for the current set tracked by the compiler. This would fix your command:

    Code:
        compile
            page
                -name=page1
                -in=page1.html
                -out=${build.dir}/page1.html
                -classes=page1.js
            and
            restore
                page1
            and
            concat
                ${build.dir}/page1.js
    The "-classes" option lets you change the name of the "all-classes.js" script that will be written to the html file.

    Since you are building just one page, you can use the short-hand form of the page command, which is enabled by not naming the page's file set. For example:

    Code:
        compile
            page
                -in=page1.html
                -out=${build.dir}/page1.html
                -classes=page1.js
    Or you can build all of your pages in one compile command (for faster builds):

    Code:
        compile
            page
                -name=page1
                -in=page1.html
                -out=${build.dir}/page1.html
                -classes=page1.js
            and
            page
                -name=page2
                -in=page2.html
                -out=${build.dir}/page2.html
                -classes=page2.js
            and
            page
                -name=page3
                -in=page3.html
                -out=${build.dir}/page3.html
                -classes=page3.js
            and
            restore
                page1
            and
            concat
                ${build.dir}/page1.js
            and
            restore
                page2
            and
            concat
                ${build.dir}/page2.js
            and
            restore
                page3
            and
            concat
                ${build.dir}/page3.js
    Don Griffin
    Ext JS Development Team Lead

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

    "Use the source, Luke!"

  3. #3
    Sencha User
    Join Date
    Mar 2009
    Location
    Reading, UK
    Posts
    33
    Vote Rating
    1
    Curtis Fletcher is on a distinguished road

      0  

    Default


    Thanks for the reply.

    I created the scaffolding by moving my app out of the way and creating a new scaffold in what was the app directory (thus creating the .sencha directory) then removing the ./app and html scaffold and copying my app back into the directory.

    The plugin.xml I provided was indeed .sencha/app/plugin.xml this was under the advice of kkrohe here http://www.sencha.com/forum/showthread.php?244917-3.0.0.181-Ext-JS-4.1.1a-unable-to-disable-yui-compression

    A
    s it stands I've actually given up on using sencha cmd, instead I'm using ext-all and a perl script that concats my app classes in a sensible order and runs the yui-compressor on it if needed. I'll probably look at it again when it's much more stable.

  4. #4
    Sencha - Ext JS Dev Team dongryphon's Avatar
    Join Date
    Jul 2009
    Posts
    1,295
    Vote Rating
    121
    dongryphon is a name known to all dongryphon is a name known to all dongryphon is a name known to all dongryphon is a name known to all dongryphon is a name known to all dongryphon is a name known to all

      0  

    Default


    Quote Originally Posted by Curtis Fletcher View Post
    Thanks for the reply.

    I created the scaffolding by moving my app out of the way and creating a new scaffold in what was the app directory (thus creating the .sencha directory) then removing the ./app and html scaffold and copying my app back into the directory.
    That makes sense. I was just double checking there since you didn't mention the presence of these in your OP... and they greatly effect the process.

    Quote Originally Posted by Curtis Fletcher View Post
    The plugin.xml I provided was indeed .sencha/app/plugin.xml this was under the advice of kkrohe here http://www.sencha.com/forum/showthre...ui-compression

    Quote Originally Posted by Kevin Krohe
    However, as a workaround for now, you should be able to override the app-build-impl target by providing a target by that name in the .sencha/app/plugin.xml file with something like the following content.
    OK, I see. I think the workaround Kevin recommended can be removed since that bug is fixed. The fact that the command was (slightly) incorrect is why you were getting all files vs the files for only the page you wanted.

    In this case, because you have 3 "apps" in one folder structure, you will likely need to be calling the compiler directly to get the result you are after rather than try to use "sencha app build".

    Quote Originally Posted by Curtis Fletcher View Post
    As it stands I've actually given up on using sencha cmd, instead I'm using ext-all and a perl script that concats my app classes in a sensible order and runs the yui-compressor on it if needed. I'll probably look at it again when it's much more stable.
    Certainly sorry to hear that - especially in this case as it seems the issue you are having is now just in how to craft the command you need to isolate the respective pieces of your 3 pages. I understand that you don't have unlimited time, however.

    Good luck either way you go.
    Don Griffin
    Ext JS Development Team Lead

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

    "Use the source, Luke!"

Thread Participants: 1