SPFX Notes
SPFX Notes
SPFX Notes
webpack.config.js example:
const path = require('path');
module.exports = {
entry: './src/index.js',
output: {
path: path.resolve(__dirname, 'dist'),
filename: 'bundle.js'
}
};
npm install –g yo
To run:
yo electron
Install gulp:
npm install -g gulp
spfx environment:
NoYoGenGulp (trick to learn)
Q. How to move web part created for one site collection to other?
Ans: We will deploy it to the app gallery of the specific site collection and then it
will be available for that specific collection.
Q. Question asked while creating SharePoint template:
Ans. Blue are the newly added.
What is your solution name?
Which baseline package do you want to target for your component?
SharePoint Online Only
SharePoint 2016 onwards, including 2019 and SharePoint Online
SharePoint 2019 onwards, including SharePoint Online
Where do you want to place the files?
Do you want to allow the tenant admin the choice of being able to deploy
the solution to all sites immediately without running any feature deployment
or adding apps in sites? (Globally Deployed if choose Yes)
Which type of client-side component to create?
WebPart
Extension
Library
What is your web part name?
What is your web part description?
Which framework would you like to use?
ReactJS
KnokoutJS
No Javascript framework
----------------------------------------------------------------------------------------------------
Structure of WebPart code:
Src folder:
webparts folder:
<webpartName> folder (eg. helloWorld)
HelloWorldWebPart.manifest.json
HelloWorldWebPart.module.scss
HelloWorldWebPart.ts
o export interface I*WebPartProps { description: string;}
o export default class *WebPart extends
BaseClientSideWebPart<I*WebPartProps> {
ReadMore: http://mundrisoft.com/tech-bytes/create-custom-client-side-web-part-using-sharepoint-framework-spfx/
Changes in New:
1.
export interface IHelloWorldWebPartProps {
description: string;
This interface was the part of I*WebPartProps.ts but now it is part of *WebPart.ts
How to add property to Property pane of WebPart:
1. Import the required property at top of the *webpart.ts file.
2. Add the property to the groupFields array of getPropertyPaneConfiguration
method
After above two methods our property would be shown to the property pane of web
part. If you want to use that property value in the render() then follow the below two
steps also.
3. Add property name and type in I* WebPartProps interface.
4. Use the property in render() as ${escape(this.properties.<propertyname>)}
escape() Converts the characters "&", "<", ">", '"', "'", and "`" in string to their corresponding HTML
entities.
How to ge the Environment details inside webpart: (TRICK: earth core manages the
environment)
Just Import the Environment and EnvironmentType from @microsoft/sp-core-library':
import{
Environment,EnvironmentType
}from '@microsoft/sp-core-library';
Site Setting is via Site Information (from setting Gear icon at upper right of the page). We can’t navigate
directly to site setting.
Permission on Site via Share site Information (from setting Gear icon at upper right of the page).
Some months ago, Modern Sites were at Site Collection level but recently launched that we can create
Modern site at sub site level too but only of Type “Team Site”.
To move PowerApp from one environment to another, we can Export-Import the PowerApp.
We need to reestablish the connections and manually configure it for the lists.
https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/ customize-list-form