Skip to content

Commit 590828d

Browse files
authored
chore: update sp-webpart sample to spfx v1.15 (#1776)
* fix: update spfx webpart sample to use v1.15.0 * ensure dev workbench usage works and update docs
1 parent be9c83e commit 590828d

File tree

7 files changed

+35
-80
lines changed

7 files changed

+35
-80
lines changed

samples/sp-webpart/.eslintrc.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
require('@rushstack/eslint-config/patch/modern-module-resolution');
2+
module.exports = {
3+
extends: ['@microsoft/eslint-config-spfx/lib/profiles/default'],
4+
parserOptions: { tsconfigRootDir: __dirname }
5+
};

samples/sp-webpart/README.md

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,19 @@ Run the webpart by running:
2828

2929
`gulp serve`
3030

31+
In the output from the `gulp serve` command you will see a query string to load your scripts e.g.:
32+
```
33+
[spfx-serve] To load your scripts, use this query string: ?debug=true&noredir=true&debugManifestsFile=https://localhost:4321/temp/manifests.js
34+
```
35+
Copy this query string value.
36+
3137
Open the browser to:
3238

33-
`https://<your-tenant>.sharepoint.com/_layouts/15/Workbench.aspx`
39+
`https://<your-tenant>.sharepoint.com/_layouts/15/Workbench.aspx<copied-query-string>`
3440

35-
The webpart will be available to be added
41+
After trusting the scripts the webpart will be available to be added
3642

37-
### Approving permissions
43+
### Approving permissions
3844

3945
The admin of your tenant will need to approve the graph permissions in the admin portal before you can use any graph APIs. You only need to do these steps once (or if you add additional permissions to `config/package-solution.json`)
4046

@@ -50,7 +56,7 @@ The admin of your tenant will need to approve the graph permissions in the admin
5056
5157
2. Upload the package to an app catalog. Navigate to the app catalog url and click on *Distribute apps for SharePoint*. Click on *new* to upload the solution to the app catalog and deploy it.
5258
53-
> If you do not have an app catalog on your tenant, follow [these steps](https://docs.microsoft.com/en-us/sharepoint/use-app-catalog#step-1-create-the-app-catalog-site-collection) to create one.
59+
> If you do not have an app catalog on your tenant, follow [these steps](https://docs.microsoft.com/en-us/sharepoint/use-app-catalog#step-1-create-the-app-catalog-site-collection) to create one.
5460
5561
3. Approve the permissions. Go to the SharePoint admin center (best reached via https://admin.microsoft.com > click **Show All** > SharePoint) and make sure you are signed in as admin.
5662

samples/sp-webpart/config/serve.json

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,5 @@
22
"$schema": "https://developer.microsoft.com/json-schemas/core-build/serve.schema.json",
33
"port": 4321,
44
"https": true,
5-
"initialPage": "https://localhost:5432/workbench",
6-
"api": {
7-
"port": 5432,
8-
"entryPath": "node_modules/@microsoft/sp-webpart-workbench/lib/api/"
9-
}
5+
"initialPage": "https://{Your-SharePoint-site}/_layouts/workbench.aspx?debug=true&noredir=true&debugManifestsFile=https://localhost:4321/temp/manifests.js"
106
}

samples/sp-webpart/gulpfile.js

Lines changed: 2 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,8 @@
11
'use strict';
22

3-
const gulp = require('gulp');
43
const build = require('@microsoft/sp-build-web');
5-
build.addSuppression(`Warning - [sass] The local CSS class 'ms-Grid' is not camelCase and will not be type-safe.`);
6-
7-
build.configureWebpack.mergeConfig({
8-
additionalConfiguration: generatedConfiguration => {
9-
generatedConfiguration.module.rules.push({
10-
test: /\.m?js$/,
11-
use: {
12-
loader: 'babel-loader',
13-
options: {
14-
presets: [
15-
[
16-
'@babel/preset-env',
17-
{
18-
targets: {
19-
ie: '11'
20-
}
21-
}
22-
]
23-
]
24-
}
25-
}
26-
});
274

28-
return generatedConfiguration;
29-
}
30-
});
5+
build.addSuppression(`Warning - [sass] The local CSS class 'ms-Grid' is not camelCase and will not be type-safe.`);
316

327
var getTasks = build.rig.getTasks;
338
build.rig.getTasks = function () {
@@ -38,4 +13,4 @@ build.rig.getTasks = function () {
3813
return result;
3914
};
4015

41-
build.initialize(gulp);
16+
build.initialize(require('gulp'));

samples/sp-webpart/package.json

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,28 +11,30 @@
1111
"dependencies": {
1212
"@microsoft/mgt-react": "*",
1313
"@microsoft/mgt-spfx": "*",
14-
"@microsoft/sp-core-library": "1.13.0",
15-
"@microsoft/sp-lodash-subset": "1.13.0",
16-
"@microsoft/sp-office-ui-fabric-core": "1.13.0",
17-
"@microsoft/sp-property-pane": "1.13.0",
18-
"@microsoft/sp-webpart-base": "1.13.0",
19-
"office-ui-fabric-react": "7.156.0",
14+
"@microsoft/sp-core-library": "1.15.0",
15+
"@microsoft/sp-lodash-subset": "1.15.0",
16+
"@microsoft/sp-office-ui-fabric-core": "1.15.0",
17+
"@microsoft/sp-property-pane": "1.15.0",
18+
"@microsoft/sp-webpart-base": "1.15.0",
19+
"office-ui-fabric-react": "7.185.7",
2020
"react": "16.9.0",
2121
"react-dom": "16.9.0"
2222
},
2323
"resolutions": {
2424
"@types/react": "16.9.36"
2525
},
2626
"devDependencies": {
27+
"@microsoft/eslint-config-spfx": "1.15.0",
28+
"@microsoft/eslint-plugin-spfx": "1.15.0",
29+
"@microsoft/rush-stack-compiler-4.5": "0.2.2",
30+
"@microsoft/sp-build-web": "1.15.0",
31+
"@microsoft/sp-module-interfaces": "1.15.0",
2732
"@types/react": "16.9.36",
2833
"@types/react-dom": "16.9.8",
29-
"@microsoft/sp-build-web": "1.13.0",
30-
"@microsoft/sp-tslint-rules": "1.13.0",
31-
"@microsoft/sp-module-interfaces": "1.13.0",
32-
"@microsoft/sp-webpart-workbench": "1.12.1",
33-
"@microsoft/rush-stack-compiler-3.9": "0.4.47",
34-
"gulp": "4.0.2",
34+
"@types/webpack-env": "1.13.1",
35+
"@rushstack/eslint-config": "2.5.1",
3536
"ajv": "~5.2.2",
36-
"@types/webpack-env": "1.13.1"
37+
"eslint-plugin-react-hooks": "4.3.0",
38+
"gulp": "4.0.2"
3739
}
3840
}

samples/sp-webpart/tsconfig.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"extends": "../../node_modules/@microsoft/rush-stack-compiler-3.9/includes/tsconfig-web.json",
2+
"extends": "../../node_modules/@microsoft/rush-stack-compiler-4.5/includes/tsconfig-web.json",
33
"compilerOptions": {
44
"target": "es5",
55
"forceConsistentCasingInFileNames": true,
@@ -14,6 +14,7 @@
1414
"inlineSources": false,
1515
"strictNullChecks": false,
1616
"noUnusedLocals": false,
17+
"rootDir": "src",
1718
"typeRoots": ["./node_modules/@types", "./node_modules/@microsoft"],
1819
"types": ["webpack-env"],
1920
"lib": ["es5", "dom", "es2015.collection", "es2015.promise"]

samples/sp-webpart/tslint.json

Lines changed: 0 additions & 30 deletions
This file was deleted.

0 commit comments

Comments
 (0)