SPFX setup & deployment
Setting up SharePoint Framework (SPFx) for SharePoint Online involves several steps. Below is a guide to help you set up SharePoint Framework for SharePoint Online compatibility:
Note: please refer below link to get latest update
https://learn.microsoft.com/en-us/sharepoint/dev/spfx/set-up-your-development-environment
Prerequisites:
Node.js and npm:
- Ensure you have Node.js installed. You can download it from nodejs.org.
- spfx support version => node-v18.17.1-x64
- npm and yomen -> >npm install -g yo gulp
- >npm install -g @microsoft/generator-sharepoint
- SPFx generally works with the LTS (Long-Term Support) version of Node.js.
Yeoman and Gulp:
- Install Yeoman and Gulp globally using npm.
bashnpm install -g yo gulp
SharePoint Online Tenant Configuration:
- Developer Site:
- Create a developer site collection in your SharePoint Online tenant. This site collection is used for testing your SPFx web parts.
- App Catalog:
- Create an App Catalog site collection in your SharePoint Online tenant if you don't have one. This is where you will deploy your SPFx packages.
Set Up Your Development Environment:
SharePoint Yeoman Generator:
- Install the SharePoint Yeoman generator globally.
bashnpm install -g @microsoft/generator-sharepoint
Generate a New SPFx Project:
- Create a new directory for your project and navigate into it.
bashyo @microsoft/sharepoint
- Follow the prompts to create your SPFx solution. Choose "SharePoint Online only (latest)" when prompted for the target SharePoint environment.
Code Your Web Part:
- Write your web part code in the generated project.
Connect to SharePoint Online:
Update the
./config/serve.json
file:- Set
gulp serve --nobrowser
in thelaunchTask
property. This prevents the gulp task from opening a browser window automatically.
- Set
Configure the CDN Path (Optional, but recommended for production):
- Update the
cdnBasePath
property in the./config/write-manifests.json
file to specify the CDN path where your assets will be hosted.
- Update the
Build and Test Your Web Part Locally:
- Run your SPFx solution locally to test your web part.
bashgulp serve
Package and Deploy Your Web Part:
Bundle and Package:
- Bundle and package your solution for deployment.
bash=> gulp bundle --ship =>
gulp package-solution --shipUpload to App Catalog:
- Upload the
.sppkg
file from thesharepoint/solution
folder to the App Catalog.
- Upload the
Add Web Part to a Page:
- Go to the site where you want to add the web part and add it from the web part picker.
Your SPFx web part is now deployed and running on SharePoint Online. Keep in mind that this is a basic setup guide, and you might need additional configurations based on your project requirements. Always refer to the official SharePoint Framework documentation and Microsoft 365 developer documentation for the most up-to-date information.
Comments
Post a Comment