To run your web part locally is simply a case of using gulp serve. There is no connection available to any SharePoint lists or libraries when run this way, but there is an easy way around this that has been kindly provided.
Running locally
As mentioned, running locally is as simple as executing gulp serve from the command line. A browser window is opened with the localhost address.
https://localhost:4321/temp/workbench.html
The workbench is a simple recreation with enough functionality, styles and layout to emulate a SharePoint page. The web part you have created can be added and tested to the extent of using mock data you provide to it.
Running on SharePoint
Running on SharePoint is just as simple. Execute gulp serve on the command line, or gulp serve --nobrowser to avoid opening the local workbench and then open a browser window to your SharePoint site and append to '/_layouts/15/Workbench.aspx' the end.
For example:
https://YourCompany.sharepoint.com/sites/Your-Site/_layouts/15/Workbench.aspx
The same workbench is opened and your web part can be added to the page. Only this time the web part can use PnPJS or direct calls to the REST API to interact with SharePoint.
Comments