9

My app.json file of a Sencha touch 2 application contain.

"js": [
    {
        "path": "sdk/sencha-touch.js"
    },
    {"path": "js/mootools-1.2.5-core.js"}, // I want these files to be bundled too
    {"path": "js/mootools-1.2.5.1-more.js"}, // <----------+
    {"path": "js/soundmanager2-nodebug-jsmin.js"}, // <----+
           ...                                     // <----+ and there are more.
           ...

    {
        "path": "app.js",
        "bundle": true,  /* Indicates that all class dependencies are concatenated into this file when build */
        "update": "delta"
    },

Now I see when I invoke sencha app build production It compiles all the sencha classes into a giant app.js file. But all my other classes are just compressed to build directory. They are not concatenated. how can I include them in app.js?

F.A.Q.

  1. Your json file is properly written, right?

    A. Yes, app.json is written without any syntax error. The project builds successfully on invoking sencha app build production

Community
  • 1
  • 1
Shiplu Mokaddim
  • 56,364
  • 17
  • 141
  • 187

2 Answers2

16

After looking at the source code and talking with the devs behind Cmd, it appears that it is currently not possible.

However, because the build file is written in JavaScript, in theory, it wouldn't take much to modify it and add this functionality into Cmd.

You can find the Sencha Touch build file in:

CMD-ROOT/plugins/touch/current/app-build.js

Where CMD-ROOT is the location of the sencha command - which you can find out by using which sencha.

On my system (OSX), the path is:

/Users/Robert/bin/Sencha/Cmd/3.0.0.250/plugins/touch/current/app-build.js

Hopefully this is of some help to you.

Update

It appears that, after talking to another Cmd developer, this actually is possible. There are 2 steps you need to take to make it happen:

1) Add the skipFrameworkFile property into each JS resource you want to bundle. This tells the compiler to not copy the resource when your build your app.

{
    "path": "resources/js/jquery.js",
    "skipFrameworkFile": true
},

    "path": "resources/js/jquery2.js",
    "skipFrameworkFile": true
}

2) Require each of the files in your app.js file using the @require tag. This tells the compiler to include each of your files into your app.js file.

//@require resources/js/jquery.js
//@require resources/js/jquery2.js
rdougan
  • 7,217
  • 2
  • 34
  • 63
  • Thanks for the input. I in fact right now using sencha as legacy mode. I created dependency tree by `sencha create jsb`. Then added all the dependency to it before invoking `sencha build`. This works well. But as its deprecated I can not rely on this. – Shiplu Mokaddim Jan 28 '13 at 20:27
  • **Update**. Spoke with the developers again and came up with a workaround which should work for you. Let me know if it does. – rdougan Jan 28 '13 at 22:37
  • I have tried it. But no luck. I still see its requesting 'mootools.js' and others over the network. Also the app.js file size does not increase at all. See my stripped down [app.js](http://pastie.org/5926797) and [app.json](http://pastie.org/5926859) – Shiplu Mokaddim Jan 29 '13 at 11:02
  • Odd, as I have tested it and it works. What version of Cmd are you running? I'm running `Sencha Cmd v3.0.0.250` – rdougan Jan 29 '13 at 12:28
  • I am using `Sencha Command v2.0.0 Beta 3`. Its available on their web as recommended. http://www.sencha.com/products/sdk-tools/download/ – Shiplu Mokaddim Jan 29 '13 at 12:49
  • Ah, that would be why. That is an older product. Try using Cmd: http://www.sencha.com/blog/all-new-sencha-cmd/ – rdougan Jan 29 '13 at 13:36
  • 1
    I checked it in the new Sencha Cmd 3.0. It works!! I am now in the process of converting the whole project to Latest ST2 – Shiplu Mokaddim Feb 02 '13 at 21:41
  • This is a partial solution for me. With Sencha Cmd v4.0.0.203, I am able to bundle external JS into `app.js` with step (2) as outlined by @rdougan, but if I modify `app.json` according to step (1) then I get an error during the build: `[ERR] The following error occurred while executing this line: /var/www/flux-client/.sencha/app/build-impl.xml:359: The following error occurred while executing this line: /var/www/flux-client/.sencha/app/js-impl.xml:11: java.lang.NullPointerException`. – Arthur Feb 20 '14 at 17:36
  • second step works with "'x-bootstrap': true" instead of "skipFrameworkFile: true" in sencha cmd 4.0.4.84. Thanks @rdougan – Amod Apr 02 '15 at 05:02
4

For SenchaCmd 3.2, rdougan's solution didn't work for me. However, instead of using:

'skipFrameworkFile: true

I used

'x-bootstrap': true

(by looking at SenchaCmd source code) and it worked!

The other steps are the same as rdougan's

Hope this helps. Cheers

Edgar Villegas Alvarado
  • 18,204
  • 2
  • 42
  • 61