I am building an Angular application (Angular 4/5/6) and would like to use SVG sprites in my component template.
Question: Assuming I already have my S
I think your root path is where you are having problems. In your code you are telling angular to look in app but the browser sees this as https://your-site.com./icons
If you move your icon file under your /assets folder, then it should be available already because the src\assets folder is already included in angular.json, the "assets" collection tells Angular where to look.
If you would like your files to be served from another directory all you need to do is add a path in your angular.json:
…
"assets": [
"src/favicon.ico",
"src/assets",
"src/your-dir"
],
…
Then in your code
I wouldn't suggest adding /src/app as an asset path, this would basically open up your entire app for serving files, making your entire directory accessible.
I forked your example and updated here