Create SP Library as CDN (Upload SPFx webpart assets into SharePoint library)

 To make SharePoint Library as CDN:

        In this post we can see how to add asset files separately instead of adding in SPFx sppkg file. 

       By default all the assets will be added under "ClientSideAssets" library of AppCatalog site (If config/package-solution.json >  includeClientSideAssets is true)


        We can also upload assets into into SharePoint library and make it as a CDN for sppkg package file. (If   config/package-solution.json --> includeClientSideAssets is false)
 config/write-manifests.json --> cdnBasePathis --> add SP Library name where we upload assets


Create a new document library & set readonly permission to everyone so that every one in this site can access the assets of webpart.

After that run "gulp bundle --ship" & "gulp package-solution --ship" comments in VS code, it will create asset files under "release/assets" folder & upload those files into SP Library.
Also upload "sharepoint/solution/" sppkg file under appcatalog.


Now the SPFx webpart take the asset files from the SP library as a CDN & working as expected.




Refer this video for more details

Comments

Popular posts from this blog

Upload Single/Multiple file by using the REST API and jQuery SharePoint 2013

A type named 'SP.Data. could not be resolved by the model error

Add content type to SharePoint List/Library using REST API