Build Ionic app and web app with angular-cli+ionic-cli from single repo

Problem:
How would you setup a ionic project with angular cli so you can build web app and ionic app from single code repository? + Also I might want to build PWA app later as well.

Just do not want to avoid of copy-pasting to much if you see what I mean. I saw some related questions people looking to achieve same thing but I didn’t found a clear answer to that yet.

Some one saying to create a responsive app and then adapt it to ionic.
Someone saying just use ionic for all cases (as I am new to ionic I cant clearly see how it would work, also it is sounds not quite right to me but please correct me if i’m wrong on this one).

Goal:
I want is just to have responsive web app that would work well on all devices which I know how to do and I want to build hybrid app as well to give people such option.

Solution that I am thinning of:
So for my current understanding I can build a web app first and then adapt it for ionic but then I want to keep everything what can be shared in sync (services, models, etc) - do not want to duplicate the code, what share all what possible between the web and mobile apps, That is why I am looking for a solution that I can build multiple apps from single repository. Say in the end of the day I can run a command on my repository like ng build and get app angular-cli to build my web app. Then run ionic build and get the app build for mobile. So the project structure could be looking like that:

App-proj(3 separate folders per one project) e.g https://github.com/strictd/angular2-ionic2-webpack
|––angular-app-folder
|
––ionic-app-folder
|
––shared-folder (components,services,etc)

OR

3 Separate projects:

–– angular-cli-proj
|
–– shared-modules-proj(components,services,etc)
|
–– ionic-cli-proj

Anyone can advice on that?
In such case should I consider web first or ionic first ?

3 Likes

Good to see your article.
I want to make web app and hybrid app in one repository based on Angular CLI instead of Ionic CLI.
Did you find any other solution about this?
I want to talk about this issue.

thanks.

Did you find the answer? Is it possible to use 1 repo?

I think you could even fit it all into one project. Just check in your code if the plugins are available or make a var modified by a hook that change the app depending wether its native or a web app. I used the last option and it worked fine.

1 Like