I am currently working on a webcomponent where I need to include a link
tag in the head section and set the href
attribute to a folder within a node module.
At this stage, during the development of my component, my project structure looks like this:
https://i.stack.imgur.com/3IRw1.png
My goal is to add the fontawesome.css
stylesheet to the head of my page. For this purpose, I have created the following script:
constructor() {
super();
if (!this.isFontAwesomeLoaded()) {
this.iclass = '';
const fontEl = document.createElement('link');
fontEl.rel = 'stylesheet';
fontEl.href = "./fontawesome/css/all.css";
document.head.appendChild(fontEl);
}
}
However, there is an issue with the path ./fontawesome/css/all.css
when it reaches the head
tag because the index.html
file loading the script lacks the necessary folder in its project structure. Instead, upon reaching production, it needs to determine the absolute path to my module and then locate the fontawesome
folder.
My question is: How can I obtain that path?