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

javascript - Change project directory structure in Cordova - Stack Overflow

programmeradmin1浏览0评论

When we create a new project in cordova we get below folders:

App
 |- hooks
 |- platforms
 |- plugins
 |- www
 |- config.xml

But per our client has a standard project structure across the projects, they want project structure should be somewhat similar to like this:

App
|- build
|- plugins
|- release
    |- platforms
        |-Android
        |-ios
|- src
    |- www
|- config.xml

Is there anyway to achieve this structure (or basically chage the defauly project structure generated by cordova CLI) ? I searched a lot and didnt find any userful information regarding this. Kindly help me.

When we create a new project in cordova we get below folders:

App
 |- hooks
 |- platforms
 |- plugins
 |- www
 |- config.xml

But per our client has a standard project structure across the projects, they want project structure should be somewhat similar to like this:

App
|- build
|- plugins
|- release
    |- platforms
        |-Android
        |-ios
|- src
    |- www
|- config.xml

Is there anyway to achieve this structure (or basically chage the defauly project structure generated by cordova CLI) ? I searched a lot and didnt find any userful information regarding this. Kindly help me.

Share Improve this question asked Aug 31, 2015 at 6:46 Pradeep SimhaPradeep Simha 18.1k19 gold badges59 silver badges112 bronze badges 3
  • 1 Well if it is the standard structure for cordova, then why your clients are so eager to change that. Best you can do is write a grunt or gulp task and put release builds in release folder. – Mudasser Ajaz Commented Aug 31, 2015 at 7:12
  • Well it's their organisation standard structure, they need to follow it seams. – Pradeep Simha Commented Aug 31, 2015 at 7:22
  • If you change the cordova structure some thing won't work (or maybe any). – jcesarmobile Commented Sep 8, 2015 at 12:09
Add a ment  | 

1 Answer 1

Reset to default 9

In general, I find that 'standard project structure' is actually pretty specific to a particular language/context, or to a few with similar characteristics. And Cordova is its own particular context, with its own 'standard project structure'. And while you want to make life easy for your humans where you can, by reducing their cognitive friction when moving between contexts, you need to be flexible about that in cases that won't support it.

This is one of those cases. Significantly, Cordova simply doesn't offer any configuration options for the paths. The Cordova CLI has very specific, very rigid expectations, and doesn't offer to let us modify those expectations via an .rc file or something. It probably could, if someone wanted to prioritize that feature. But as of 5.x, it doesn't.

Our shop has hundreds of Cordova builds in production, created by many teams. And quite a few of those teams, ing from different languages and approaches, have attempted to impose their will upon Cordova and to rearrange its folder structure. (I'm on one such team right now...) To the very best of my knowledge, and from consultation with our resident go-to guy on Cordova, none of them have truly succeeded, at least not without significant hacky workarounds that exceeded the value of the alleged consistency. (Like scripts that copy all the files from where you want them, to where Cordova actually requires them, runs the build there, then cleans up again afterwards.)

I think that until Cordova explicitly supports alternate folder structures, folks are ill-advised to fight it on this. But this is opinion, not fact. The only fact is: Cordova doesn't itself support doing what you want to do, so it'll take you lots of work to get around that.

发布评论

评论列表(0)

  1. 暂无评论