Skip to content

Commit 2713fc2

Browse files
estruyfVesaJuvonen
authored andcommitted
Added the Microsoft Edge debugging information (SharePoint#1847)
1 parent 8573ea1 commit 2713fc2

File tree

2 files changed

+76
-8
lines changed

2 files changed

+76
-8
lines changed
Loading

docs/spfx/debug-in-vscode.md

Lines changed: 76 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,16 @@ You can also see the required steps to enable debugging in Visual Studio Code in
2020

2121
## Prerequisites
2222

23-
The easiest way to configure Visual Studio Code to debug SharePoint Framework solutions is by using Google Chrome and the Debugger for Chrome Visual Studio Code extension. Starting with the SharePoint Framework Yeoman generator version 1.3.4, the default project (web parts and extensions) templates come set up with the prerequisites and prompt for the required Visual Studio Code extensions to install. In this case, it prompts to install Debugger for Chrome Visual Studio Code extension.
23+
The easiest way to configure Visual Studio Code to debug SharePoint Framework solutions is by using the [Debugger for Chrome](https://marketplace.visualstudio.com/items?itemName=msjsdiag.debugger-for-chrome) or [Debugger for Edge](https://marketplace.visualstudio.com/items?itemName=msjsdiag.debugger-for-edge) Visual Studio Code extensions.
24+
25+
Starting with the SharePoint Framework Yeoman generator version 1.3.4, the default project (web parts and extensions) templates come set up with the prerequisites and prompt for the required Visual Studio Code extensions to install. In this case, it prompts to install Debugger for Chrome Visual Studio Code extension.
2426

2527
You also need the Google Chrome browser. [Download and install the latest version of Google Chrome](https://www.google.com/chrome/browser/desktop/index.html).
2628

2729
If you are using a version of SharePoint Framework Yeoman generator that is older than version 1.3.4, you can [install the Chrome debugger extension for Visual Studio Code from the Visual Studio Marketplace](https://marketplace.visualstudio.com/items?itemName=msjsdiag.debugger-for-chrome).
2830

31+
In case you want to debug your projects with Microsoft Edge, you need to [install the Debugger for Edge extension for Visual Studio Code from the Visual Studio Marketplace](https://marketplace.visualstudio.com/items?itemName=msjsdiag.debugger-for-edge) and follow the steps in [Debugging with Microsoft Edge or older projects](#debugging-with-microsoft-edge-or-older-projects).
32+
2933
## Debug configurations
3034

3135
You can locate the debug configurations in the launch.json file under the Visual Studio Code workspace folder:
@@ -118,9 +122,12 @@ When building SharePoint Framework solutions, you will be doing such tests regul
118122

119123
![Breakpoint hit in Visual Studio Code when debugging a SharePoint Framework client-side web part in the hosted workbench](../images/vscode-debugging-breakpoint-hit-o365.png)
120124

121-
## For older projects
125+
## Debugging with Microsoft Edge or older projects
122126

123-
If you are using an older version of SharePoint Framework Yeoman generator, follow these steps to create the launch.json file manually.
127+
If you are using an older version of SharePoint Framework Yeoman generator or want to debug with Microsoft Edge, follow these steps to create the launch.json file manually.
128+
129+
> [!NOTE]
130+
> In order for you to debug with Microsoft Edge, you will have to install the **Windows 10 April 2018 Update** which includes the Microsoft Edge DevTools Protocol.
124131

125132
### Create debug configuration for local workbench
126133

@@ -132,11 +139,36 @@ If you are using an older version of SharePoint Framework Yeoman generator, foll
132139

133140
![The Add Configuration option highlighted in the debug configurations drop-down](../images/vscode-debugging-add-debug-configuration.png)
134141

135-
3. In the list of debug environments, select **Chrome**.
142+
3. In the list of debug environments, select **Edge** or **Chrome**.
143+
144+
![Chrome highlighted as the debug environment for the new configuration](../images/vscode-debugging-edge-chrome-environment.png)
145+
146+
4. For **Edge**, replace the contents of the generated **launch.json** file with:
147+
148+
```json
149+
{
150+
"version": "0.2.0",
151+
"configurations": [
152+
{
153+
"name": "Local workbench",
154+
"type": "edge",
155+
"request": "launch",
156+
"url": "https://localhost:4321/temp/workbench.html",
157+
"webRoot": "${workspaceRoot}",
158+
"sourceMaps": true,
159+
"sourceMapPathOverrides": {
160+
"webpack:///../../../src/*": "${webRoot}/src/*",
161+
"webpack:///../../../../src/*": "${webRoot}/src/*",
162+
"webpack:///../../../../../src/*": "${webRoot}/src/*"
163+
}
164+
}
165+
]
166+
}
167+
```
136168

137-
![Chrome highlighted as the debug environment for the new configuration](../images/vscode-debugging-chrome-debug-environment.png)
169+
This configuration uses the **Edge** debugger provided with the **Debugger for Edge** extension. It points to the URL of the local workbench as the starting point. What is essential in debugging TypeScript code is the configuration of source maps that the debugger uses to map the JavaScript running in the browser to the original TypeScript code.
138170

139-
4. Replace the contents of the generated **launch.json** file with:
171+
5. For **Chrome**, replace the contents of the generated **launch.json** file with:
140172

141173
```json
142174
{
@@ -166,9 +198,45 @@ If you are using an older version of SharePoint Framework Yeoman generator, foll
166198

167199
### Create debug configuration for hosted workbench
168200

169-
1. In Visual Studio Code, open the **./.vscode/launch.json** file.
201+
1. In Visual Studio Code, open the **./.vscode/launch.json** file.
202+
203+
2. For **Edge**, copy the existing debug configuration and use the URL of the hosted workbench:
204+
205+
```json
206+
{
207+
"version": "0.2.0",
208+
"configurations": [
209+
{
210+
"name": "Local workbench",
211+
"type": "edge",
212+
"request": "launch",
213+
"url": "https://localhost:4321/temp/workbench.html",
214+
"webRoot": "${workspaceRoot}",
215+
"sourceMaps": true,
216+
"sourceMapPathOverrides": {
217+
"webpack:///../../../src/*": "${webRoot}/src/*",
218+
"webpack:///../../../../src/*": "${webRoot}/src/*",
219+
"webpack:///../../../../../src/*": "${webRoot}/src/*"
220+
}
221+
},
222+
{
223+
"name": "Hosted workbench",
224+
"type": "edge",
225+
"request": "launch",
226+
"url": "https://contoso.sharepoint.com/_layouts/workbench.aspx",
227+
"webRoot": "${workspaceRoot}",
228+
"sourceMaps": true,
229+
"sourceMapPathOverrides": {
230+
"webpack:///../../../src/*": "${webRoot}/src/*",
231+
"webpack:///../../../../src/*": "${webRoot}/src/*",
232+
"webpack:///../../../../../src/*": "${webRoot}/src/*"
233+
}
234+
}
235+
]
236+
}
237+
```
170238

171-
2. Copy the existing debug configuration and use the URL of the hosted workbench:
239+
3. For **Chrome**, copy the existing debug configuration and use the URL of the hosted workbench:
172240

173241
```json
174242
{

0 commit comments

Comments
 (0)