Why ionic search build/assets for fonts


#1

I run npm run ionic:build -prod to build my PWA project. After every build, I change the path “build/” to “build/versionxx” on the index.html for handling cache busting. However, after I change the path, ionic starts looking for fonts under path “build/assets” instead of “assets/”. Why?
If I want to version my assets folder as well, where should I change the “assets/” to “assets/versionxx”?
Can anyone help me pls?
@reedrichards hi reedrichards, do you have any idea?
@rapropos hi robert, can you please help me?


[PWA] Service worker app cache duration
#2

not sure actually, my first question would be why are you busting the cache every time ?


#3

Because every release I make consists of lots of changes. If I didn’t do it, my customers has problems with their browser cache. They might get a blank page. I use aws cloudfront, s3, it’s quite difficult to figure out what the best practice is.


#4

I see, to be honest, I don’t know, I’m with you, no idea what’s the production strategy to apply. I opened that question without answer a while back [PWA] Service worker app cache duration

About s3, I think I did a change to always fetch the http request without cache. To do so I have modified the following in service-worker.js

 // https://github.com/GoogleChromeLabs/sw-toolbox/blob/master/docs/api.md
 self.toolbox.router.default = self.toolbox.networkOnly;

There are probably some strategies but I don’t know more…looking forward to hear about the outcome of your post


#5

Because every release I make consists of lots of changes. If I didn’t do it, my customers has problems with their browser cache. They might get a blank page. I use aws cloudfront, s3, it’s quite difficult to figure out what the best practice is.
[/quote]

I couldn’t agree more. To find the best practice for production isn’t easy and there is not much could be found online. People who know the stuff are either too busy or …

anyway, thx for jump in every time. I am nearly done with my web app. it’s time to tight the loose ends. Currently, I even disable the service worker because this whole cache thing is driving my crazy. I I will keep you updated about my findings.


#6

What about using a Service Worker?

Angular’s support for Service Workers is provided by the @angular/service-worker module. You can add Angular’s Service Worker (NGSW) module to your Ionic project using npm:

npm install @angular/service-worker --save

See:


#7

@robinyo7h you mean using angular/service-worker instead of sw-toolbox?

if I may ask, what would be the advantages? and doing so, the same cache issue wouldn’t be faced too?


#8

Just finished reading the docs. I’d say the angular sw implementation adds some CLI, API and documentation sugar to the core service worker implementation. I reckon Angular is going to expand on this API to smoothen the developer experience.

I still find service-workers tough cookies to digest reading all sorts of blogs and various caching strategies (also not having that much time to try stuff)


#9

Yes.

Well said.

Post must be at at least 20 characters.


#10

Hi robinyo, thanks for the help. I will take a look at it. btw, do you have any idea about the assets path change?


#11

Don’t know exactly but maybe there is a way to set your subfolder versionxxx at build time not afterwards in order to prefix both assets and build folders? like a config of ionic cli or app-script?


#12

@lolaswift have a look to [PWA] Service worker app cache duration maybe could be another solution to invalidate the cache without having to change manually versionxxx has you actually does and therefore would solve your fonts issue too


#13

@reedrichards. Definite will do!
thanks again!


#14

the Service worker from angular 6.x is pretty good however, I am still using ionic3 with angular 5. maybe it’s a good idea to wait for ionic 4? I guess it should work with angular 6?

Currently, I work around my problem by versioning my build folder and assets folder. And it works well.


#15

don’t have the reference right here but if I remember correctly I saw a tweet from Justin stating that Ionic v4 respectively ionic-angular v4 will comes with Angular v6


#16

that would be great. To be honest, I still feel more comfortable staying with ionic-angular instead of going stencil. Angular is getting better and better.


#17

You are not alone and probably a lot of existing productive app will not be modified from angular to stencil in a first place


#18

Knowing angullar is going to support webcomponents too why bother stencil? Anyway, off topic


#19

I agree! I believe the stencil path will gain it’s popularity as well. At the end of the day, just use the right tool to do the right thing. I am excited to learn stencil as well. To be honest, I love ionic but I am a bit disappointed at the Ionic team about how they are running their business. The organization is not mature yet and they are still struggling with finding their own business model. I am having a lots of pain now supporting my ionic 1.x which is being ignored by the team and there isn’t much attention being put on supporting the community ionic 3.x either. If they have some sort of business plan and if those plans are consistent, I’d be happy to pay to get some support. That’s actually another reason why I want to stay with ionic-angular, the angular community is bigger and lots of issues are discovered and solved a lot faster. Now I am even further away off the topic. :smile:. it doesn’t matter though. I got my help from you guys. Especially @reedrichards. And I solve my problem by manually renaming my folder names after the build. It sounds a bit clumsy but it’s working for me. I hope this workaround will help the others as well.


#20

@Tommertom @lolaswift what I meant is that modifying an existing productive app has a cost respectively would cost money

I’m just guessing that most companies in a first place straight at the begin of Ionic v4 might not invest in a migration from angular to stencil for costs reason