Provision SharePoint assets using SPFx

SharePoint assets can be provisioned as part of the SharePoint Framework solution, and are deployed to SharePoint sites when the solution is installed on it.
Steps:1 Perform below code to configure a web part package.

md asset-deployment-webpart // Create a directory to your desire location
cd asset-deployment-webpart // Go to project directory
yo @microsoft/sharepoint // Create a new client side web part solution using 
code . //enter the following to open the web part project in VS Code
Create folder structure for your SharePoint assets

We first need to create an assets folder where we place all feature framework assets used to provision SharePoint structures when a package is installed.
1. Create a folder called sharepoint to the root of the solution
2. Create a folder called assets as a sub-folder for the just created sharepoint folder.
Your solution structure should look like the following picture

Feature Framework Files for initial deployment

Supported elements for the SharePoint Framework solution packages are following:
1. Field/Site Column
2. Content Types
3. List Instances
4. List Instances with custom schema

To add an element.xml file for SharePoint definitions
Step:1 Create a new file inside the sharepoint\assets folder named elements.xml
Step:2 Copy the following XML structure into elements.xml.
Using Features in SharePoint Foundation

<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="">
 <Field ID="{060E50AC-E9C1-4D3C-B1F9-DE0BCAC300F6}"
            Group="SPFx Columns" />
 <Field ID="{943E7530-5E2B-4C02-8259-CCD93A9ECB18}"
            DisplayName="Cost Center"
            Group="SPFx Columns">
    <ContentType ID="0x010042D0C1C200A14B6887742B6344675C8B" 
            Name="Cost Center" 
            Group="SPFx Content Types" 
            Description="Sample content types from web part solution">
            <FieldRef ID="{060E50AC-E9C1-4D3C-B1F9-DE0BCAC300F6}" /> 
            <FieldRef ID="{943E7530-5E2B-4C02-8259-CCD93A9ECB18}" />
            Title="SPFx List" 
            Description="SPFx List"

To add a schema.xml file for defining list structure
Step:1 Create a new file inside the sharepoint\assets folder named schema.xml
Step:2 Copy the following XML structure into schema.xml
Understand the schema.xml

<List xmlns:ows="Microsoft SharePoint" Title="Basic List" EnableContentTypes="TRUE" FolderCreation="FALSE" Direction="$Resources:Direction;" Url="Lists/Basic List" BaseType="0" xmlns="">
      <ContentTypeRef ID="0x010042D0C1C200A14B6887742B6344675C8B" />
      <View BaseViewID="1" Type="HTML" WebPartZoneID="Main" DisplayName="$Resources:core,objectiv_schema_mwsidcamlidC24;" DefaultView="TRUE" MobileView="TRUE" MobileDefaultView="TRUE" SetupPath="pages\viewpage.aspx" ImageUrl="/_layouts/images/generic.png" Url="AllItems.aspx">
        <XslLink Default="TRUE">main.xsl</XslLink>
        <RowLimit Paged="TRUE">30</RowLimit>
        <Toolbar Type="Standard" />
          <FieldRef Name="LinkTitle"></FieldRef>
          <FieldRef Name="SPFxAmount"></FieldRef>
          <FieldRef Name="SPFxCostCenter"></FieldRef>
            <FieldRef Name="ID" />
      <Form Type="DisplayForm" Url="DispForm.aspx" SetupPath="pages\form.aspx" WebPartZoneID="Main" />
      <Form Type="EditForm" Url="EditForm.aspx" SetupPath="pages\form.aspx" WebPartZoneID="Main" />
      <Form Type="NewForm" Url="NewForm.aspx" SetupPath="pages\form.aspx" WebPartZoneID="Main" />

Click here to get sample element.xml and schema.xml

Use definitions in build pipeline

Step:1 Open package-solution.json from the config folder
Copy below code after “IsDomainIsolated”:flase

"features": [{
      "title": "asset-deployment-webpart-client-side-solution",
      "description": "asset-deployment-webpart-client-side-solution",
      "id": "523fe887-ced5-4036-b564-8dad5c6c6e24",     // <-- Update 'id' with a new GUID
      "version": "",
      "assets": {
        "elementManifests": [

Deploy and test asset provisioning

Run below code in terminal in VS Code

gulp bundle
gulp package-solution
command generate a sppkg file in location sharepoint/solution/debug

Deploy the package that was generated to the app catalog. Go to your tenant’s app catalog.

Upload or drag and drop the asset-deployment-webpart.sppkg located in the sharepoint/solution folder to the app catalog. Deploy the package that was generated to the app catalog. Go to your tenant’s app catalog.

Refrence Link

Click here to get solution

Sharing is caring !!
Happy Coding 🙂

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.