Can SPFx Webpart and Extension exist in a single app?
-
01-01-2021 - |
Question
I'm starting to get my hands on using the new SharePoint Framework.
I have general ideas about how they work now but I couldn't any document or statement that they (Client Web Part and Extension) could be in a same solution/app to deploy together.
If anyone could point me to the right way that would be awesome !!.
Many thanks,
Solution
Yes, you can have multiple webparts or extensions in the same solution. Think of it as a Visual Studio solution with multiple projects (i.e one sln file and multiple dlls).
To add a webpart/extension in the existing solution, you simply need to run the yeoman generator again.
yo @microsoft/sharepoint
- run this command in your current solution and the generator is intelligent enough to add the webpart/extension. It internally checks for config.json file and if it exists appends the new "project" there.
To see those, 2 for example(1 webpart and 1 extension), you can go to the config > config.json
file. In that file, you will see it as below:
OTHER TIPS
Yes, you can create as many web parts or extensions on a single solution. You can watch this SharePoint PnP video to know more about that. https://www.youtube.com/watch?v=Sm5UocF8mcQ