I am trying to develop a PWA using Ionic, I have completed few of modules of my project but I noticed that bundle size is too big and I started digging regarding this. I tried to put main.js , main.css and polyfills.js in some other server which decreased bundle size from 1.8mb to 786kb.
So, I just wanted to know if it’s alright to do so or it’s not the right way to achieve my goal.
Kindly provide your suggestions regarding this.
Thanks in advance.
How did you build your app?
@Sujan12 I started the service using ionic serve command and then I copied main.js & main.css & polyfills.js files to some other server and put that same path in index.html.
It’s working fine. I just want to know whether this is the right thing to do or not !
That’s why I am asking: It is not.
npm run build --prod and then copy the contents of
/www to your server. Should be much smaller and faster.
@Sujan12 Original size of my project was 6.0mb and then i started service with
ionic serve and then i put
npm run build --prod command, bundle size reduced to 1.8mb and it was still too huge that’s why I used this way. If you have any other optimisation way kindly let me know.
--prod with lazy loading for some things and the initial bundle download will decrease further. There is not much else you can do I think.