These steps will give an overview of creating a modern SPFx WebPart to an existing solution.
- Access the solution using the command prompt or powershell
- Access the
spfx
folder - Run
yo @microsoft/sharepoint
(You must run this within thespfx
folder) a) Select theWebPart
for thetype
b) Set the name c) Set the description d) SelectNo JavaScript framework
- After the files are created run
npm i
orpnpm i
to install the libraries - Access the
spfx/config/package-solution.json
and update the following properties a) name b) developer name and website url properties c) Update the zippedPackage to have the following value../../dist/project.sppkg
- Access the
spfx/src/webparts/project/name.ts
webpart file - Append the import statement
import "../../../../dist/project.min.js"; declare var GlobalVariableName;
- Replace the render method with the following code
public render(): void { // Render the application GlobalVariableName.render(this.domElement, this.context.pageContext); }
- Run
npm run all
from the root project folder to build the solution files and SPfx package