最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Instruct Sencha SDK tools to bundle other js files specified in app.json - Stack Overflow

programmeradmin2浏览0评论

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

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

Share Improve this question edited Jun 20, 2020 at 9:12 CommunityBot 11 silver badge asked Jan 24, 2013 at 18:00 Shiplu MokaddimShiplu Mokaddim 57.7k20 gold badges145 silver badges192 bronze badges
Add a comment  | 

2 Answers 2

Reset to default 16 +100

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

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

发布评论

评论列表(0)

  1. 暂无评论