SOLVED

How to set a path of asset library in spfx web part?

%3CLINGO-SUB%20id%3D%22lingo-sub-1538867%22%20slang%3D%22en-US%22%3EHow%20to%20set%20a%20path%20of%20asset%20library%20in%20spfx%20web%20part%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1538867%22%20slang%3D%22en-US%22%3E%3CP%3EHi%2C%3C%2FP%3E%3CP%3EI'm%20trying%20to%20use%20SharePoint%20asset%20folder%20for%20js%20files%20(webpart%5Ctemp%5Cdeploy)%20that%20generate%20with%20the%20web%20part.%20I%20added%20that%20path%20in%20the%20CDN%20but%20I'm%20still%20getting%20this%20on%20deployment%20that%20client%20side%20solution%20will%20get%20content%20from%20localhost.%3C%2FP%3E%3CP%3EThis%20client%20side%20solution%20will%20get%20content%20from%20the%20following%20domains%3A%3C%2FP%3E%3CP%3E%3CSPAN%3Ehttps%3A%2F%2Flocalhost%3A4321%2F%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThanks%2C%3C%2FP%3E%3CP%3E-Sal%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1538867%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3ESharePoint%20Online%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1538945%22%20slang%3D%22en-US%22%3ERe%3A%20How%20to%20set%20a%20path%20of%20asset%20library%20in%20spfx%20web%20part%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1538945%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F736673%22%20target%3D%22_blank%22%3E%40ejagmtg%3C%2FA%3E%2C%3C%2FP%3E%3CP%3EIf%20you%20are%20looking%20for%20hosting%20your%20client-side%20web%20part%20from%20Microsoft%20365%20CDN%20then%20check%20below%20references%3A%3C%2FP%3E%3COL%3E%3CLI%3E%3CA%20title%3D%22Host%20your%20client-side%20web%20part%20from%20Microsoft%20365%20CDN%22%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fsharepoint%2Fdev%2Fspfx%2Fweb-parts%2Fget-started%2Fhosting-webpart-from-office-365-cdn%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3EHost%20your%20client-side%20web%20part%20from%20Microsoft%20365%20CDN%3C%2FA%3E%26nbsp%3B%3C%2FLI%3E%3CLI%3E%3CA%20title%3D%22SharePoint%20Framework%20-%20Deploy%20SPFx%20WebParts%20To%20Office%20365%20Public%20CDN%22%20href%3D%22https%3A%2F%2Fwww.c-sharpcorner.com%2Farticle%2Fsharepoint-framework-deploy-spfx-webparts-to-office-365-public-cdn%2F%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noreferrer%22%3ESharePoint%20Framework%20-%20Deploy%20SPFx%20WebParts%20To%20Office%20365%20Public%20CDN%3C%2FA%3E%26nbsp%3B%3C%2FLI%3E%3C%2FOL%3E%3CHR%20%2F%3E%3CP%3EPlease%20click%20%3CSTRONG%3EMark%20as%20Best%20Response%3C%2FSTRONG%3E%20if%20my%20post%20helped%20you%20solve%20your%20issue.%20This%20will%20help%20others%20find%20the%20correct%20solution%20easily.%20It%20also%20closes%20the%20item.%20If%20the%20content%20was%20useful%20in%20other%20ways%2C%20please%20consider%20giving%20it%20%3CSTRONG%3E%3CSTRONG%3ELike%3C%2FSTRONG%3E%3C%2FSTRONG%3E.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1539035%22%20slang%3D%22en-US%22%3ERe%3A%20How%20to%20set%20a%20path%20of%20asset%20library%20in%20spfx%20web%20part%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1539035%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F373269%22%20target%3D%22_blank%22%3E%40ganeshsanap%3C%2FA%3E%26nbsp%3BThanks%20for%20the%20response%2C%20I%20read%20both%20links%20but%20not%20able%20to%20get%20the%20settings%20correct.%20I%20set%20the%20path%20in%20the%20cdnBasePath%20write-manifest.json%20but%20still%20showing%20me%20localhost%20when%20I%20try%20to%20upload%20the%20package.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThanks%2C%3C%2FP%3E%3CP%3E-Sal%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1542738%22%20slang%3D%22en-US%22%3ERe%3A%20How%20to%20set%20a%20path%20of%20asset%20library%20in%20spfx%20web%20part%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1542738%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F736673%22%20target%3D%22_blank%22%3E%40ejagmtg%3C%2FA%3E%26nbsp%3BUse%20SharePoint%20frame%20work%201.4%20or%20higher%2C%20if%20we%20do%20that%20then%20we%20can%20just%20include%20an%20option%20%3CSPAN%3E%22includeClientSideAssets%22%3C%2FSPAN%3E%3CSPAN%3E%3A%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3Etrue%26nbsp%3B%3C%2FSPAN%3Ein%20Package-solution.json%20%3CSPAN%3E%2C%20that%20include%20all%20asset%20files%20with%20the%20package%20solution%20file%20and%20then%20you%20can%20just%20upload%20one%20file%20to%20the%20app%20catalog%20and%20all%20set%20with%20the%20webpart.%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E
Occasional Contributor

Hi,

I'm trying to use SharePoint asset folder for js files (webpart\temp\deploy) that generate with the web part. I added that path in the CDN but I'm still getting this on deployment that client side solution will get content from localhost.

This client side solution will get content from the following domains:

https://localhost:4321/

 

Thanks,

-Sal

3 Replies

@ejagmtg,

If you are looking for hosting your client-side web part from Microsoft 365 CDN then check below references:

  1. Host your client-side web part from Microsoft 365 CDN 
  2. SharePoint Framework - Deploy SPFx WebParts To Office 365 Public CDN 

Please click Mark as Best Response if my post helped you solve your issue. This will help others find the correct solution easily. It also closes the item. If the content was useful in other ways, please consider giving it Like.

@ganeshsanap Thanks for the response, I read both links but not able to get the settings correct. I set the path in the cdnBasePath write-manifest.json but still showing me localhost when I try to upload the package.

 

Thanks,

-Sal

best response confirmed by ejagmtg (Occasional Contributor)
Solution

@ejagmtg Use SharePoint frame work 1.4 or higher, if we do that then we can just include an option "includeClientSideAssets"true in Package-solution.json , that include all asset files with the package solution file and then you can just upload one file to the app catalog and all set with the webpart.