Monday 16 August 2021

Build your first client-side web part using SharePoint Framework

Create a new web part project:

Create a new project directory for your project and change your current folder to that directory.

Create a new project by running the Yeoman SharePoint Generator from within the new directory you created: yo @microsoft/sharepoint

Important Note:

NPM may display warnings and error messages during the installation of dependencies while it runs the npm install command. You can safely ignore these log warnings & error messages.

NPM may display a message about running npm audit at the end of the process. Don't run this command as it will upgrade packages and nested dependencies that may not have been tested by the SharePoint Framework.

Trusting the self-signed developer certificate

The client-side toolchain uses HTTPS endpoints by default. Part of the Set up your development environment process included trusting the development SSL certificate included in the toolchain on your local environment. This is required so your browser will trust the certificate.

Note:Trusting the developer certificate is required. This is a one-time process and is only required when you run your first SharePoint Framework project on a new workstation. You don't need to do this for every SharePoint Framework project.

Run this command: gulp trust-dev-cert

You will be asked to install the certificate. Click Yes

To check the structure of the code: Code .

Update your project's hosted workbench URL

Update the initialPage in serve.json to your SharePoint site and go to Terminal from View menu(If you want to run the command from Code.)

Tip: You can also start the local web server without launching a browser by including the nobrowser argument to the gulp serve command. For example, you may not want to modify the serve.json file in all your projects and instead, use a bookmark to launch your hosted workbench.

gulp serve --nobrowser

Start the local web server & launch the hosted workbench by running this command: 

gulp serve 

Use SharePoint Workbench to preview and test your web part:

After configuring the webpart property pane changes

No comments:

Post a Comment