How to include @ionic/pwa-elements in an Ionic4/Angular build


#1

Hi there, I’m new to Ionic4, but have been using Angular for some time so am currently experimenting with an Ionic4/Angular app.

I’ve been looking to integrate capacitor to access native functionality from a PWA, and I’ve got some tests working with the camera plugin, however I have to include a reference to an external pwa-elements script in my index.html as per: https://capacitor.ionicframework.com/docs/getting-started/pwa-elements/

This is no good if I want the app to be able to work offline, so I’m trying to get this imported and bundled within the Ionic/Angular build, but it’s not clear from the docs how to do that in an Angular context.

I’ve added “import ‘@ionic/pwa-elements’;” to my app.module.ts, but that doesn’t seem to work. I’ve tried manually referencing the ionicpwaelements.js script in the scripts section of my angular.json file, but ionicpwaelements.js references a bunch of other js files in the ‘ionicpwaelements’ sub directory in node modules, which it can’t find (and would be too arduous to reference them all).

How do I import ionic/pwa-elements into an Ionic4/Angular app?