How to package ionic to run on Linux


#1

I was asked to build a simple POC app for a doc signing solution to prove some unknowns. We had a possible requirement that this may need to run on some mobile devices in future but it’s not an immediate requirement.
I did a simple UI with ionic and built the back end API with Spring-boot. I need to be able to hit from different browser types (Chrome, FireFox and IE) to prove one of my unknowns to establish the browser cache behaviour. My local dev env is MacOS. Now I need to deploy this into a Linux machine and hit from IE.

Then I realise I can’t package this for Linux. I don’t need to deploy to any mobile OS’s now. I am using the free version. I tried with below command and does not work.
ionic package build linux --profile=prod --release --prod

I couldn’t find a way to get around this. Not sure if this is because I am using the free version. Do I have to rewrite my simple javascript UI without using ionic to continue with my POC??


#2

Ionic package is deprecated

Targets for a build are ios, android or www (and maybe even wp?)

If u want to use a browser on a linux box then u neef to build for www, place the files generated under www/ folder on the box, run a webserver and surf to it

ionic build --prod

U can only build for www and android on a linux box. If u want to build for ios on linux then basically u need to have this package built in the cloud platform ionic provides (and pay apple for dev license)


#3

Thanks for the reply @Tommertom

I am only deploying on Linux but developing on a Mac. I use the browsers on a different Windows machine to hit the application running on Linux.

If I only deploy the content in www folder into Linux, and ran “ionic serve” it complained that it can’t find tsconfig.json which is not copied into www folder. Therefore I copied the entire content in the next level folders which managed to start with “ionic serve”.

But I don’t think I am doing it right. There must be a way to just package everything required in the www folder.


#4

After you do a prod build of your PWA you just need to serve the contents of the /www directory.

For example:

npm run build --prod
npm install http-server -g
http-server ./www

Then navigate to:

http://localhost:8100

Don’t use “ionic serve” in a Production environment!

Use Nginx (for example) to serve you static assets or Google Hosting’s free tier:

npm run build --prod
firebase deploy

See: https://robferguson.org/blog/2017/08/12/migrating-from-ghost-0-x-to-ghost-1-x/


#5

@robinyo is providing the missing link (even if your app is not a PWA)

Ionic serve

Is not intended for serving prod, only dev workflows