Learn how assets are tied to the feature framework of SharePoint and how an SPFx solution references features.
Let me open this in VS Code, and back here, I will run yarn install, so in the background it does the node module installation for me. Now the reason I prefer to use this route, is because yarn install is a little bit faster. Especially on repeat runs. Okay, so let that run in the background, and let's come here. Now here, the way the feature provisioning framework works is, number one, in my package-solution.json I'm going to add, after version, a new node called features.
Now this is an array, in which I can specify one or more features that will get activated when I add this app into a site. Now, a little important note here, that there is another question that we were asked during the creation of the solution. Which was that, "Do you want tenant-level deployment?" So, the idea behind tenant-level deployment is that there is another flag up here called skip feature deployment.
And if this skip feature deployment, the default value is false, but if I was to set this to true, basically what that means is that the underlying assets in here become available immediately, all across your form. However, there is a downside of that, that the features, these features that I'm about to specify in here, they don't get activated. So what I'm about to show you here, will work only if skip feature deployment is no, which is the default, or missing.
So let's go ahead and drop in the details for this feature, so it is going to need a title, so I'll just call this spfx feature. It is going to need an ID, which is a GUID, so let me go ahead and paste in a GUID. So just go ahead and get a GUID and copy-paste it, and drop it in here. Let's give it a description, and then let's give it a version, 22.214.171.124 and then let's specify the details of my feature.
So, I'm going to have a node in here called assets, and in here I will have elementManifests. So those of you who are familiar with the feature provisioning framework, you know exactly what this is. So, elementFiles and elementManifests. Let's go ahead and drop those. And here, I'm going to type in elements.xml and let's say that we want to create a new list and the details of that go in schema.xml.
Now these are regular SharePoint concepts. The elements.xml, elementManifests, elementFiles, so if you're familiar with SharePoint development, yes, all of that knowledge transports over here. So, the question now, is "Where do I place "this elements.xml and schema.xml file?" The answer is that you need to place this file in a folder called SharePoint. So here, let me go ahead and create a new folder, called SharePoint, create a folder under here called assets, and under assets, I will create a new file called elements.xml and schema.xml.
So you see here that these two files that have been mentioned here, they are relative to this path here. So now all that's left, is to drop actual code inside elements.xml and schema.xml. Let's see that next.
- Creating SPFx web parts
- Debugging SPFx web parts
- Deploying SPFx solutions with an Office 365 CDM
- Provisioning SharePoint assets
- Deploying application customizers
- Creating field customizers
- Building command sets