# Deploying PWA

**URL:** <https://forum.ionicframework.com/t/deploying-pwa/73749>\
**Category:** ionic-v3\
**Created:** [December 19, 2016, 2:40pm UTC](https://forum.ionicframework.com/t/deploying-pwa/73749 "2016-12-19T14:40:09Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![alex\_key](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/alex_key/32/103500_2.png) [@alex\_key](https://forum.ionicframework.com/u/alex_key)\
**Post date:** [December 19, 2016, 2:40pm UTC](https://forum.ionicframework.com/t/deploying-pwa/73749/1 "2016-12-19T14:40:09Z")

</div>

Hey!  
I’ve been scouring the net trying to find some info on how to build and deploy an ionic 2 app as a PWA, but no luck. So I resort to posting here. If anyone could be so kind as to explain how to build and deploy a normal ionic 2 application (standard template is fine) to run as a PWA I’d be very grateful!

Thanks!

---

<div class="post-metadata">

**Author:** ![CarlRyds](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/carlryds/32/101344_2.png) [@CarlRyds](https://forum.ionicframework.com/u/CarlRyds)\
**Post date:** [December 19, 2016, 3:25pm UTC](https://forum.ionicframework.com/t/deploying-pwa/73749/2 "2016-12-19T15:25:03Z")

</div>

Hi,

For what I can tell you make an Ionic 2 app (as PWA comes pre-set-up in an Ionic 2 App), build it using `ionic serve --lab` and then upload the files in the www folder to your web server. That’s what I did and it seems to work.

That’s probably not the proper way of doing it but like I say it worked for me.

Hope that helps.  
Carl

---

<div class="post-metadata">

**Author:** ![mirkonasato](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/mirkonasato/32/131398_2.png) [@mirkonasato](https://forum.ionicframework.com/u/mirkonasato)\
**Post date:** [December 19, 2016, 3:27pm UTC](https://forum.ionicframework.com/t/deploying-pwa/73749/3 "2016-12-19T15:27:38Z")

</div>

`ionic serve` creates a “dev” build; for production you may want to run

```auto
npm run ionic:build --prod

```

and deploy what’s in the `www` folder.

---

<div class="post-metadata">

**Author:** ![ChrisGriiffith](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/chrisgriiffith/32/66576_2.png) [@ChrisGriiffith](https://forum.ionicframework.com/u/ChrisGriiffith)\
**Post date:** [December 19, 2016, 4:17pm UTC](https://forum.ionicframework.com/t/deploying-pwa/73749/4 "2016-12-19T16:17:51Z")

</div>

And to add to building the app in production mode, you probably will also want to remove the calls to Cordova as that will not work in the browser

Chris  
author, “[Mobile App Development with Ionic 2](http://shop.oreilly.com/product/0636920044710.do)”

---

<div class="post-metadata">

**Author:** ![beck24](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/beck24/32/112174_2.png) [@beck24](https://forum.ionicframework.com/u/beck24)\
**Post date:** [December 19, 2016, 5:46pm UTC](https://forum.ionicframework.com/t/deploying-pwa/73749/5 "2016-12-19T17:46:07Z")

</div>

Not sure what the difference is, or if there is any (maybe some additional possible plugin support?), but you can also add “browser” as a platform with

```
ionic platform add browser

```

Then you can build with

```
ionic build browser --prod
```

---

<div class="post-metadata">

**Author:** ![alex\_key](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/alex_key/32/103500_2.png) [@alex\_key](https://forum.ionicframework.com/u/alex_key)\
**Post date:** [December 21, 2016, 7:29am UTC](https://forum.ionicframework.com/t/deploying-pwa/73749/6 "2016-12-21T07:29:06Z")

</div>

Yeah, I’ve gotten that far. But as for what do to with the files I am a bit clueless. I also noticed that on my desktop browser I get a 404 because cordova.js is missing. Changing the path in the index.html solves this however, but I am not sure if this is the way to do it or if you’re expected to add more libraries?

---

<div class="post-metadata">

**Author:** ![DeeM52](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/deem52/32/101606_2.png) [@DeeM52](https://forum.ionicframework.com/u/DeeM52)\
**Post date:** [December 21, 2016, 11:16am UTC](https://forum.ionicframework.com/t/deploying-pwa/73749/7 "2016-12-21T11:16:02Z")

</div>

> [@alex\_key](#):
>
> But as for what do to with the files I am a bit clueless. I also noticed that on my desktop browser I get a 404 because cordova.js is missing. Changing the path

I am trying to assemble info on PWA amd gather everything in one place. I have tried to write up a quick guide on how to deploy it. Let me know if it’s helpful or what changes would you like to have.

> [@Building for browsers - PWA](https://forum.ionicframework.com/t/building-for-browsers-pwa/72689/3):
>
> Quickstarter for your first PWA site including a small hackish approach for your content to keep looking great. 1) Initial Commands Creating an ionic app from a tab starter ionic start TesTPWATabs tabs --v2 From project root, adding support for browser ionic platform add browser Running your PWA site ionic run browser Your site is contained in the /www folder. This is the folder you’ll need to deploy (Step 3) 2) Hackish approach - Setting max-width to 600 pixels when in browsers In app…

---

<div class="post-metadata">

**Author:** ![mirkonasato](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/mirkonasato/32/131398_2.png) [@mirkonasato](https://forum.ionicframework.com/u/mirkonasato)\
**Post date:** [December 21, 2016, 2:20pm UTC](https://forum.ionicframework.com/t/deploying-pwa/73749/8 "2016-12-21T14:20:34Z")

</div>

If you do `ionic build browser --prod` it will include the Cordova JavaScript files as well, but you need to deploy what’s in `platforms/browser/www`, not in the top-level `www` folder.

However unless you specifically need a Cordova plugin that runs in the browser I wouldn’t worry about that. Less JavaScript files to be downloaded by the client is better.

---

<div class="post-metadata">

**Author:** ![sebastianovide](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/sebastianovide/32/97090_2.png) [@sebastianovide](https://forum.ionicframework.com/u/sebastianovide)\
**Post date:** [January 11, 2017, 9:19pm UTC](https://forum.ionicframework.com/t/deploying-pwa/73749/9 "2017-01-11T21:19:44Z")

</div>

as the file generated have always the same names, how do you force the browser to load a new version after a deployment ? (it will get it from cache until expiration) thanks.

---

<div class="post-metadata">

**Author:** ![alex\_key](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/alex_key/32/103500_2.png) [@alex\_key](https://forum.ionicframework.com/u/alex_key)\
**Post date:** [January 16, 2017, 1:16pm UTC](https://forum.ionicframework.com/t/deploying-pwa/73749/10 "2017-01-16T13:16:44Z")

</div>

Thanks! I got it working!

---

<div class="post-metadata">

**Author:** ![shepard](https://avatars.discourse-cdn.com/v4/letter/s/f14d63/32.png) [@shepard](https://forum.ionicframework.com/u/shepard)\
**Post date:** [January 16, 2017, 5:09pm UTC](https://forum.ionicframework.com/t/deploying-pwa/73749/11 "2017-01-16T17:09:37Z")

</div>

When I run ionic build browser --prod  
I get the following error:  
ionic2 failed at the ionic-hello-world@ ionic:build script 'ionic-app-scripts

The browser platform is added.

Ionic info:

cordova CLI: 6.4.0  
Ionic Framework Version: 2.0.0-rc.5  
Ionic CLI Version: 2.1.18  
Ionic App Lib Version: 2.1.9  
Ionic App Scripts Version: 1.0.0  
ios-deploy version: Not installed  
ios-sim version: Not installed  
OS: Windows 10  
Node Version: v6.8.0

---

<div class="post-metadata">

**Author:** ![dugwood](https://avatars.discourse-cdn.com/v4/letter/d/74df32/32.png) [@dugwood](https://forum.ionicframework.com/u/dugwood)\
**Post date:** [February 14, 2017, 10:36am UTC](https://forum.ionicframework.com/t/deploying-pwa/73749/12 "2017-02-14T10:36:38Z")

</div>

@sebastianovide you can rewrite HTML on the fly (with PHP or so), and include expiry dates (for example the modification time of the file). Or just adjust the cache settings in your server, see [http://www.mnot.net/cache\_docs/](http://www.mnot.net/cache_docs/) for instance.

---

<div class="post-metadata">

**Author:** ![RaulGM](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/raulgm/32/144112_2.png) [@RaulGM](https://forum.ionicframework.com/u/RaulGM)\
**Post date:** [February 20, 2017, 3:07pm UTC](https://forum.ionicframework.com/t/deploying-pwa/73749/13 "2017-02-20T15:07:31Z")

</div>

I’ve tried this without success. The error I get is

`No default language could be detected for this app.`

I mean, everything is javascript, but it doesn’t accept it.

---

<div class="post-metadata">

**Author:** ![jiahao1553](https://avatars.discourse-cdn.com/v4/letter/j/e480ec/32.png) [@jiahao1553](https://forum.ionicframework.com/u/jiahao1553)\
**Post date:** [March 1, 2017, 3:06am UTC](https://forum.ionicframework.com/t/deploying-pwa/73749/14 "2017-03-01T03:06:40Z")

</div>

Just an addition, for Ionic 2.2.1, to build a production ready PWA, you may run this command:  
`npm run build --prod`  
Documentation is provided here: [https://github.com/driftyco/ionic-app-scripts](https://github.com/driftyco/ionic-app-scripts)

---

<div class="post-metadata">

**Author:** ![RaulGM](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/raulgm/32/144112_2.png) [@RaulGM](https://forum.ionicframework.com/u/RaulGM)\
**Post date:** [March 1, 2017, 5:57pm UTC](https://forum.ionicframework.com/t/deploying-pwa/73749/15 "2017-03-01T17:57:38Z")

</div>

I just wanted everybody to know that pages do not behave as angular components, the web page has a little delay once you change tab or push a page. I’m recoding it to be pure angular2.

---

<div class="post-metadata">

**Author:** ![rodneyjoyce](https://avatars.discourse-cdn.com/v4/letter/r/839c29/32.png) [@rodneyjoyce](https://forum.ionicframework.com/u/rodneyjoyce)\
**Post date:** [October 6, 2017, 6:05pm UTC](https://forum.ionicframework.com/t/deploying-pwa/73749/16 "2017-10-06T18:05:23Z")

</div>

> [@beck24](#):
>
> ionic platform add browser

Can anyone explain what the benefit of adding the browser platform is?

---

<div class="post-metadata">

**Author:** ![beck24](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/beck24/32/112174_2.png) [@beck24](https://forum.ionicframework.com/u/beck24)\
**Post date:** [October 6, 2017, 6:31pm UTC](https://forum.ionicframework.com/t/deploying-pwa/73749/17 "2017-10-06T18:31:02Z")

</div>

Adding the browser platform gives you access to cordova functions and plugins that support the browser platform.  
The support is certainly less than ios/android though so it’s not exactly the same, but ok for some functions.

---

<div class="post-metadata">

**Author:** ![rodneyjoyce](https://avatars.discourse-cdn.com/v4/letter/r/839c29/32.png) [@rodneyjoyce](https://forum.ionicframework.com/u/rodneyjoyce)\
**Post date:** [October 6, 2017, 6:38pm UTC](https://forum.ionicframework.com/t/deploying-pwa/73749/18 "2017-10-06T18:38:36Z")

</div>

Ok, thanks, I think I get it. So for my PWA, IF there is a browser implementation the plugin should work automatically. If not, I need to check what platform I am on and implement a web version of the plugin if needed…

I could also ignore the Browser platform completely and do the platform check and implementation for all of them.

Does that sound about right?

---

<div class="post-metadata">

**Author:** ![beck24](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/beck24/32/112174_2.png) [@beck24](https://forum.ionicframework.com/u/beck24)\
**Post date:** [October 6, 2017, 6:40pm UTC](https://forum.ionicframework.com/t/deploying-pwa/73749/19 "2017-10-06T18:40:21Z")

</div>

Yeah that’s correct, it’s much easier if the plugin has browser support. Otherwise you will need to sniff the platform and do workarounds.

---

<div class="post-metadata">

**Author:** ![rodneyjoyce](https://avatars.discourse-cdn.com/v4/letter/r/839c29/32.png) [@rodneyjoyce](https://forum.ionicframework.com/u/rodneyjoyce)\
**Post date:** [October 6, 2017, 7:14pm UTC](https://forum.ionicframework.com/t/deploying-pwa/73749/20 "2017-10-06T19:14:26Z")

</div>

Thanks. Maybe you would know this: I have a single code base for my native apps and now my new PWA. If I comment out the Service Worker in index.html in the source folder, will it affect my native app cordova build (I use Ionic Cloud to create the native packages). IE do I have to have 2 different Index.html files?

[Next page](https://forum.ionicframework.com/t/deploying-pwa/73749.md?page=2)
