Cordoba Build - Ignore Files

When compiling the cordova application, each individual file in my /www folder is copied to the assets/www (android) folder, but I would like to configure which files will be copied. I use several pseudo-languages, such as CoffeeScript, Jade or Stylus, which are automatically compiled by my IDE, and they should not be sent to the final application.

+10
android cordova cordova-3
source share
6 answers

With the help of this article, I found that you can create / edit platform/android/ant.properties and add the following line to it:

 aapt.ignore.assets=!*.map:!thumbs.db:!.git:.*:*~ 

In this line, any file or corresponding to one of these patterns will not be included in the .apk file:

  • *.map
  • thumbs.db
  • .git
  • .*
  • *~

I found that editing platforms/android/build.xml will not work, as it is overwritten every time the assembly is called; In addition, creating the build.xml file in the root of the project did not work.

The rules for this property are as follows, taken from $ANDROID_HOME/tools/ant/build.xml :

 <!-- 'aapt.ignore.assets' is the list of file patterns to ignore under /res and /assets. Default is "!.svn:!.git:.*:<dir>_*:!CVS:!thumbs.db:!picasa.ini:!*.scc:*~" Overall patterns syntax is: [!][<dir>|<file>][*suffix-match|prefix-match*|full-match]:more:patterns... - The first character flag ! avoids printing a warning. - Pattern can have the flag "<dir>" to match only directories or "<file>" to match only files. Default is to match both. - Match is not case-sensitive. --> <property name="aapt.ignore.assets" value="" /> 
+7
source share

By default, hidden (. *) Folders and files will be ignored

All hidden files and folders will be ignored during build, for example .git/ and .gitignore

To hide: rename the folder with . (period) appended to the folder / file name.

To rename the folder with. (dot) at startup, you may need a CLI

Use a terminal on Linux / Mac to rename a folder.

 mv dev .dev 

Use cmd on Windows

 ren dev .dev 
+3
source share

I don’t know how to filter files for Cordova, but I can describe how you feel about what we use in our projects.

We use gruntjs with the phonegap plugin. We configure it to use a previously created folder (which contains only the necessary files and folders), and it:

  • creates a cordova / phonegap project
  • adds plugins, platforms
  • creates own application
  • runs its own application on the emulator

The main thing in this approach is that the cordova / phonegap project (a directory with .cordova, platforms and www folders) is just an assembly artifact.

Here is an example of our Gruntfile.js :

  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 the previous build phase and contains a concatenated and reduced version of the code.

+2
source share

I created a custom script to ignore files / folders that work not only for android:

Add this to your config.xml :

 <ignore entries="lang,foo/bar,ignore/asdf.html" /> 

And you need two more files located in the hooks / before_build and hooks / after_build folders.

+1
source share

I highly recommend cordova-plugin-exclude-files . You simply specify the files to be excluded as the pattern attributes of the exclude-files tags in your config.xml file.

For example, to exclude all .scss files:

<exclude-files pattern="**/*.scss"/>

And to exclude all files with the string "ios-only" only on the Android platform:

<platform name="android"> <exclude-files pattern="ios-only"/> </platform>

+1
source share

This is what I do. I moved the src files for the application, www folder to another folder created in the root directory - web-app . Then the following script was added to package.json :

enter image description here

This, of course, needs to be finalized, but I work with him as a temporary arrangement.

Good luck ...

0
source share

All Articles