I am currently developing some spfx webpart and i have deployed the webpart and using a SharePoint library as cdn. My question is: Can i deploy the webpart without using a cdn?
3 Answers
Yes, you can do that without having to enable CDN.
In your config > write-manifests.json
file, there is a cdnBasePath
property.
Modify that value to a document library path as below:
{
"$schema": "https://developer.microsoft.com/json-schemas/spfx-build/write-manifests.schema.json",
"cdnBasePath": "https://<tenant>.sharepoint.com/sites/test/DocLib"
}
After that, you need to upload the package in app catalog and then separately upload the files in the temp > deploy
folder to document library.
-
this is exatly what i don't want to do. can i create a single package and no need to deploy assets separately?? I am actually packaging my site to deploy to a client tenant but right now all the webparts are pointing to my tenant cdn Jan 16, 2019 at 11:53
Yes and if you are using a SharePoint Library to serve your static assets - you've deployed without an CDN :)
However, there is no way to include your assets into the .sppkg-file - it's not its purpose. Assets can be stored anywhere as long as it's accessible by the users.
[Edit] Since SharePoint Framework v1.4 assets can be included into the .sppkg-file!
Waldek Mastykarz has a great post about this. https://blog.mastykarz.nl/should-you-use-office-365-cdn/
-
@Frederik Svensson What modification do i need to do to include the assets in my .sppkg file in terms of code? Jan 16, 2019 at 11:55
-
@KeshavTaurah this is set in package-solution.json with the property includeClientSideAssets set to true. To qoute the Microsoft Docs "This change is automatic depending on your tenant settings and it does not require any changes in the actual solution package." Jan 16, 2019 at 12:04
i found the answer here . It works from sharepoint framework 1.4 and is crucial to use includeClientSideAssets