Can I use the ionic serve in production?


#1

Hi guys,

I am developing a same App for both iOS and Android platforms and also we need a web version. All the functions should be same for different platforms.

For the web version I know ionic server command can start a web server locally for debugging. But not quite sure if this can be used in production environment to provide actual services to end user?

And if so is there any way that I can deploy to different application servers? have no idea what app server the “serve” command use…


#2

The contents of the www directory can simply be served under any application server. I’ve used nginx. Naturally, none of the cordova plugin stuff will work.


#3

Hi rapropos, thanks for the reply. looks great! I will have a try on nginx as well.

And I will try to avoid using cordova plugins for example $cordovaAppVersion $cordovaFile in the code.

Thanks.


#4

just did a try. just copy the www folder under the project root to the nginx nodes will just make it work like a charm.

This is an amazing framework!


#5

If you do need some cordova stuff you can get some things to work (like camera for example) if you add the browser platform and build for it.

ionic cordova platform add browser
ionic build browser --prod

Then the source will be in platforms/browser/www
It only works with some plugins, but I’ve had success.


#6

I suggest using npm run build --prod instead of ionic serve to create the contents of the www folder before uploading it to a server, because ionic serve does a dev build without Ahead of Time (AoT) compilation and minification.


#7

thanks beck24. just know there is even a “browser” platform in ionic. i did a try and it works fine!


#8

I get this now:

$ ionic build browser --prod
The build command has been renamed. To find out more, run:

ionic cordova build --help

And under help they don’t show any commands related to building for the Web anymore… Has the ionic team removed support for building for the web??


#9

Try: ionic cordova build browser --prod


#10

ionic cordova build browser --prod --release worked, thanks!


#11

this creates a new folder under platforms folder called browser. I see platform_www and www, which do I deploy?


#12

the “www” one @phingers