Can get the current site collection url inside the "SharePoint/assets/elements.xml", inside SPFx

Valued Contributor

I am working on an SPFx web part, which inject a custom css inside the site collection. Now i define the location of the custom css file inside the ClientSideComponentProperties inside the SharePoint/assets/elements.xml file as follow:-

<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
    <CustomAction
        Title="InjectCss"
        Location="ClientSideExtension.ApplicationCustomizer"
        ClientSideComponentId="5a1fcffd-dfeb-4844-b478-1feb4325a5a7"
        ClientSideComponentProperties="{&quot;cssurl&quot;:&quot;/sites/Intranet-DEV/customcss/custom.css&quot;}">
    </CustomAction>
</Elements>
 

sc1.png

 

so in the above case the custom.css file will be located inside a site collection with this static url https://ourtenat.sharepoint.com/sites/Intranet-DEV/customcss/custom.css.. but can i change the location of the file to be dynamically inside the current site collection (where the web part will be added) ? so on each site collection i will define a library named customcss and add the custom.css file inside it? is this possible?

Thanks

0 Replies