Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use relative path in an Angular Library Component #86

Open
panagulis72 opened this issue Sep 13, 2019 · 2 comments
Open

Use relative path in an Angular Library Component #86

panagulis72 opened this issue Sep 13, 2019 · 2 comments

Comments

@panagulis72
Copy link

panagulis72 commented Sep 13, 2019

I created a custom Library with Angular Cli. It has the following structure:

  • dist
  • projects
    • customLib
      • src
        • assets
          • icons
        • lib
          • button

The button component gets as Input() the name of the svg icon that will be displayed inside the button:
this.svgIconUrl = '../../assets/icons/' +this.icon + '.svg';

I made a script which copy all icons (stored in src/assets/icons) and paste it inside dist folder. All this is working fine. Then, I published my library on bitbucket and I installed it in another Angular Application.
The Library is imported correctly, but angular-svg-icon cannot find the svg because it is taking the svg in localhost:4200/#/assets/icons/myicon.svg

And of course it doesn't find the svg, because it is inside the library, so it is inside the "node_modules" folder. How can i force the button component of Library to take the svg inside the Library, so with a relative path?

@czeckd
Copy link
Owner

czeckd commented Sep 22, 2019

You will probably need to add some additional configuration in your angular.json. See: Angular Workspace Configuration/Assets configuration.

@KurienEapen
Copy link

I'm also going through a similar scenario. I came up on this suggestions, to modify angular.json :

"assets": ["src/favicon.ico", "src/assets",
{
"glob": "**/*",
"input": "./node_modules/some-package/assets",
"output": "/assets/"
}
]

But I don't want to copy over the assets of my library to the parent application. Is there any other work around ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants