Angular – ng build –prod –base-href

angularassetsbuilddeployment

ng build –prod –base-href /gi-new –deploy-url /gi-new

I deployed angular 5 app to shared IIS server on window machine

i have uploaded contents of my dist folder to 'http://192.168.10.181/gi-new'

my app runs but the icons which are in assets are not picking correct path so they do not show on the web page.

they are using http://192.168.10.181/assets instead of /gi-new/assets

entries in
angular-cli.json

"assets": [ {
"glob": "*.svg",
"input": "../node_modules/material-design-icons/sprites/svg-sprite/",
"output": "assets/svg-icons"
}]

entries in
AppComponent

constructor(iconRegistry: MatIconRegistry, sanitizer: DomSanitizer) {
iconRegistry.addSvgIconSetInNamespace
( "action", sanitizer.bypassSecurityTrustResourceUrl("assets/svg-icons/svg-sprite-action.svg"));

how can i overcome this issue ?

Best Answer

I have encountered the same issues and manually, we need to provide proper path to all icons or .gif, .jpg whatever which comes from assets folder in your bundled file in your remote location in production mode.

e.g if you have some path like https://ip_address_name/gi-new, you need to add (/gi-new/assets/your_icon_name) everywhere in production bundled file.

This is one way to solve this particular issue.

Related Topic