Here's a basic cheat sheet for SharePoint Framework (SPFx) development, covering essential commands and steps for setting up, developing, and managing SPFx projects:
Prerequisites
- Node.js (LTS version recommended)
 - Yeoman and Gulp:bash
npm install -g yo gulp - Yeoman SharePoint Generator:bash
npm install -g @microsoft/generator-sharepoint 
Setting Up a New SPFx Project
- Create a new directory and navigate into it:bash
mkdir my-spfx-webpart cd my-spfx-webpart - Generate a new SPFx solution:
Follow the prompts to configure your project:bashyo @microsoft/sharepoint- SharePoint Online only (latest)
 - WebPart (or Extension)
 - JavaScript framework (React, No framework, etc.)
 
 
Development Commands
Serve the project locally:
bashgulp serveThis opens a local workbench in your browser where you can test your web parts.
Build the project:
bashgulp buildCompiles the project and prepares it for packaging or deployment.
Bundle the project:
bashgulp bundle --shipCreates a production-ready bundle of your project.
Package the solution:
bashgulp package-solution --shipGenerates the
.sppkgfile in thesharepoint/solutiondirectory, which can be uploaded to the App Catalog in SharePoint.
Additional Useful Commands
Clean the build directory:
bashgulp cleanRemoves old build files.
Trust Dev Cert (needed for local HTTPS):
bashgulp trust-dev-certUntrust Dev Cert:
bashgulp untrust-dev-certUpgrade SPFx project (using the Office 365 CLI):
bashnpm install -g @pnp/cli-microsoft365 m365 spfx project upgrade --output md > upgrade-report.md
File Structure Overview
- src: Contains all source code for your web parts or extensions.
- webparts: Contains web part specific files.
 - extensions: Contains extension specific files.
 
 - config: Contains configuration files for the build process.
 - sharepoint: Contains assets and deployment-related files.
- assets: Contains static assets for the project.
 - solution: Contains the packaged solution file.
 
 
Useful Links
- SPFx Documentation: SharePoint Framework Documentation
 - PnpJS: PnpJS Documentation
 - Office 365 CLI: Office 365 CLI