Skip to content
This repository has been archived by the owner on May 1, 2020. It is now read-only.

Ionic 2 RC0 Pre-Populated databases #127

Open
jgw96 opened this issue Oct 10, 2016 · 8 comments
Open

Ionic 2 RC0 Pre-Populated databases #127

jgw96 opened this issue Oct 10, 2016 · 8 comments

Comments

@jgw96
Copy link
Contributor

jgw96 commented Oct 10, 2016

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: ionic-team/ionic-framework#8583

@jgw96
Copy link
Contributor Author

jgw96 commented Oct 10, 2016

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
Copy link
Contributor Author

jgw96 commented Oct 10, 2016

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
Copy link
Contributor Author

jgw96 commented Oct 10, 2016

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
Copy link

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
Copy link
Contributor

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
Copy link

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
Copy link
Member

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

@brandyscarney
Copy link
Member

brandyscarney commented Sep 13, 2017

Sorry, wrong issue moved!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants