Files in www get deleted with every build


I have my sqlite db files in the www directory of my app, but since I upgraded to rc0 suddenly all files directly placed in www are deleted with each build. How can I now deploy my datafiles?


The assets folder under src gets included in the www folder. So if you had www/img/img.jpg before you can put the img/img.jpg folder in src/assets and then find it in www/assets/img/img.jpg.

Hope that helps!

Yes, for images and other file assets that is the way to go. But the SqlitePlugin expects the db file in the root www directory. As far as I know the window.sqlitePlugin.openDatabase does not allow a path for the filename, but I will try.



I also have the same problem. Did you find any solution? I tried putting it in assets folder in src. I can’t find the assets folder on the phone after I install it. Any idea where it’s copied? Also, did you manage to open the db from a custom location?


So here is the config file for copy which runs with every build:

The solution here would be to create your own config file and add whichever files you need copied over, similar to how index.html is copied (see the line with my-file.db):


module.exports = {
  include: [
      src: 'src/assets/',
      dest: 'www/assets/'
      src: 'src/index.html',
      dest: 'www/index.html'
      src: 'src/my-file.db',
      dest: 'www/my-file.db'
      src: 'src/service-worker.js',
      dest: 'www/service-worker.js'
      src: 'node_modules/ionic-angular/polyfills/polyfills.js',
      dest: 'www/build/polyfills.js'
      src: 'node_modules/ionicons/dist/fonts/',
      dest: 'www/assets/fonts/'

Here is the documentation behind adding a custom config file:

So you would save the above code as a file in your project, let’s call it mycopy.config.js for example, and then add it in your package.json with a path to the file. I saved it in the root of the project but you could have the config file anywhere in your project:

  "config": {
    "ionic_copy": "./mycopy.config.js"
  "scripts": {

Let me know if this doesn’t work for you! :slight_smile:


This worked perfectly. Also, we have to use cordova-sqlite-ext instead of cordova-sqlite-storage, because it offers support for prepopulated db:

let db = window.sqlitePlugin.openDatabase({
    name: "your-db-name.db",
    location: 'default',
    createFromLocation: 1


This work around is require for anyone using cordova-hot-code-push and building from a remote repo. CHCP looks for the configuration at the root of the ‘www’ folder but in the most recent release of Ionic 2, the www folder is not checked into the repo and instead is created during build time. In our case, we use BuddyBuild to build directly from a repo and without a custom BuddyBuild script to create the chcp.json and chcp.manifest, they will not exist in the final app package. In the case of iOS, this causes the app to crash immediately after the splash screen.

Here is a crash report that finally shed light on this mystery for us:

Fatal Exception NSInvalidArgumentException

*** -[NSURL URLByAppendingPathComponent:isDirectory:]: component, components, or pathExtension cannot be nil.

0 CoreFoundation
1 libobjc​.A​.dylib
2 CoreFoundation
+[NSException raise:format:]
3 Foundation
-[NSURL(NSURLPathUtilities) URLByAppendingPathComponent:isDirectory:]
4 XxXX HCPFilesStructure.m ​Line ​66
-[HCPFilesStructure localInitWithReleaseVersion:]
5 XxXX HCPFilesStructure.m ​Line ​33
-[HCPFilesStructure initWithReleaseVersion:]
6 XxXX HCPPlugin.m ​Line ​150
-[HCPPlugin doLocalInit]
7 XxXX HCPPlugin.m ​Line ​52
-[HCPPlugin pluginInitialize]
8 XxXX
-[CDVViewController registerPlugin:withClassName:]
9 XxXX
-[CDVViewController getCommandInstance:]
10 XxXX
-[CDVViewController viewDidLoad]
11 XxXX MainViewController.m ​Line ​76
-[MainViewController viewDidLoad]