Cordova Build - ignore files

前端 未结 6 766
孤街浪徒
孤街浪徒 2021-02-08 10:58

When compiling a cordova application every single file in my /www folder gets copied to the assets/www folder(android) but I\'d like to customize what

6条回答
  •  耶瑟儿~
    2021-02-08 11:40

    I do not know any way how to filter files for cordova, but I can describe you approach that we use in our projects.

    We are using gruntjs with phonegap plugin. We configure it to use prebuilt folder (which contains only necessary files and folders) and it:

    • creates cordova/phonegap project
    • adds plugins,platforms
    • builds native applicaiton
    • launches native application on emulator

    Main thing in this approach is that cordova/phonegap project (directory with .cordova, platforms and www folders) is just a build artefact.

    Here is relevant part of our Gruntfile.js as an example:

      phonegap : {
         config : {
            root : './out/dist',
            config : {
               template : './config.tpl.xml',
               data: {
                  id: pkg.id,
                  version: pkg.version,
                  name: pkg.name,
                  author : pkg.author
               }
            },
            path : 'out/phonegap',
            plugins : [
               // PHONEGAP OFFICIAL PLUGINS
               'org.apache.cordova.globalization',
               'org.apache.cordova.network-information',
               'org.apache.cordova.splashscreen',
    
               //THIRD-PARTY PLUGINS
               'de.appplant.cordova.plugin.local-notification'
            ],
            platforms : [
               'android'
            ],
            maxBuffer : 200, // You may need to raise this for iOS.
            verbose : false,
            releases : 'out/releases',
            releaseName : function() {
               return pkg.name + '-v' + pkg.version;
            },
    
            // Android-only integer version to increase with each release.
            // See http://developer.android.com/tools/publishing/versioning.html
            versionCode : function() {
               return 1;
            }
         }
      }
    

    Note, out/dist is generated by previous build step and contains concatenated and minified version of code.

提交回复
热议问题