ionicons
ionicons copied to clipboard
How to set location of icons svgs in deployment? (resourcesUrl)
I am using ionicons with Ionic 4 and angular. I would like to change the deployment to put the ionicons svg files into a different directory than svg/. I know how to do this in angular.json but I can't figure out how to tell ionicons about the new location.
There is a resourcesUrl property inside the ion-icon component that seems to figure in [1] if I could set it. I don't understand how to set it through so all components get the setting.
Does anyone know how to override the resourcesUrl path so I can point to a different location?
1: https://github.com/ionic-team/ionicons/blob/master/src/components/icon/icon.tsx#L181
any ideas other than forking ?
In need of the same capability - have some not traditional hosting I need to account for in deploying a PWA.
Any update on this?
I believe in some cases this is pretty important issue. E.g. I'm trying now to perform gradual migration of some wordpress based app into ionic and so started with embedding ionic as a page, lets say under /ionic/slug and so almost succeeded with --base-href /ionic/ and --deploy-url <dist bundle location> - unfortunately svgs used by ionic components are still tried to be loaded from /ionic/svg/. After some debugging I found that in @ionic/angular appInitialize there is a call to defineCustomElements where we could add resourcesUrl attribute which then will be passed via @ionic/core defineCustomElements from loader.js to bootstrapLazy that performs crucial setup (currently just baseURI is used):
plt.$resourcesUrl$ = new URL(options.resourcesUrl || './', doc.baseURI).href;
for my specific case that will last for several weeks unless we complete the migration to ionic I'll probably stick with patch-package to just "inject" desired location, but in general this definitely would be helpful especially for some specific PWA deployments (like this https://stackoverflow.com/questions/47885451/angular-cli-build-using-base-href-and-deploy-url-to-access-assets-on-cdn).
Hope this may be useful for someone.
This issue has been labeled as help wanted. This label is added to issues that we believe would be good for contributors.
If you'd like to work on this issue, please comment here letting us know that you would like to submit a pull request for it. This helps us to keep track of the pull request and make sure there isn't duplicated effort.
For a guide on how to create a pull request and test this project locally to see your changes, see our contributing documentation.
Thank you!