ionic-team / ionic-app-scripts

App Build Scripts for Ionic Projects
http://ionicframework.com/
MIT License
608 stars 303 forks source link

Ionic 2 RC0 Pre-Populated databases #127

Open jgw96 opened 8 years ago

jgw96 commented 8 years ago

From @iursevla on October 9, 2016 8:40

In ionic beta 11 i would put the pre-populated database on /www folder and use cordova-sqlite-ext plugin with options:

let options = { name: 'myDatabase.db', existingDatabase: true };

Now in RC0, it won't work because everytime we run (ionic run...) the www folder is overwritten. I tried to put it on /src OR in /src/assets but with no luck in both cases.

So, where should i put pre-populated databases in ionic 2 RC0 ?

Copied from original issue: driftyco/ionic#8583

jgw96 commented 8 years ago

From @stellasoft-charlie on October 10, 2016 8:40

Ionic supports writing custom config files - https://github.com/driftyco/ionic-app-scripts#custom-config-files . This will let you write your own js file where you can declare everything you would like to copy over into the www directory. create a file along side your package.json called for example, copy.config.js , inside this add the following:

module.exports = { include: [ { src: 'src/assets/', dest: 'www/assets/' }, { src: 'src/index.html', dest: 'www/index.html' }, { src: 'src/uki.db', dest: 'www/uki.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/' }, ] }; `

Then in your package.json add a config option with the following.

"config": { "ionic_copy": "./copy.config.js" },

Put the pre-populated DB in the src folder and it will copy it over along with the rest of the files

jgw96 commented 8 years ago

Hello! Thanks for opening an issue with us! As this seems like more of a support question i will urge that you ask this question on our forum and take a look at the app-scripts docs. Thanks for using Ionic!

jgw96 commented 8 years ago

Hello! I am going to reopen this issue and move it to the app-scripts repo. We are reviewing the current setup where www is treated as a throw away directory and I will use this issue to post our findings. Thanks!

iursevla commented 8 years ago

Hello! Thanks for opening an issue with us! As this seems like more of a support question i will urge that you ask this question on our forum and take a look at the app-scripts docs. Thanks for using Ionic!

I did ask the question on ionic forum but did not get any reply. So after waiting some time i decided to create an issue here.

Hello! I am going to reopen this issue and move it to the app-scripts repo. We are reviewing the current setup where www is treated as a throw away directory and I will use this issue to post our findings. Thanks!

Thanks for taking your time to review this issue.

danbucholtz commented 8 years ago

We have changed the behavior here. Only the www/build directory will be deleted now, so putting it in some location within www should work.

Please let me know if this solves your problem. I'll re-open the issue if needed.

Thanks, Dan

iursevla commented 8 years ago

Yes it won't remove the database now, it solves the problem. I can't make it work(my database request) but i guess is something to do with cordova-sqlite-ext plugin.

brandyscarney commented 7 years ago

This issue was moved to ionic-team/ionic#12879

brandyscarney commented 7 years ago

Sorry, wrong issue moved!