Skip to content

Commit 235e88f

Browse files
authored
Merge pull request #2571 from enyaxu/vscode-debug-support
Add vscode debug support
2 parents 021bac5 + e100e08 commit 235e88f

File tree

5 files changed

+94
-4
lines changed

5 files changed

+94
-4
lines changed

.vscode/launch.json

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
{
2+
// Use IntelliSense to learn about possible attributes.
3+
// Hover to view descriptions of existing attributes.
4+
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5+
"version": "0.2.0",
6+
"configurations": [
7+
8+
{
9+
"type": "node",
10+
"request": "launch",
11+
"name": "BoostNote Main",
12+
"protocol": "inspector",
13+
"runtimeExecutable": "${workspaceFolder}/node_modules/.bin/electron",
14+
"runtimeArgs": [
15+
"--remote-debugging-port=9223",
16+
"--hot",
17+
"${workspaceFolder}/index.js"
18+
],
19+
"windows": {
20+
"runtimeExecutable": "${workspaceFolder}/node_modeules/.bin/electron.cmd"
21+
}
22+
},
23+
{
24+
"type": "chrome",
25+
"request": "attach",
26+
"name": "BoostNote Renderer",
27+
"port": 9223,
28+
"webRoot": "${workspaceFolder}",
29+
"sourceMapPathOverrides": {
30+
"webpack:///./~/*": "${webRoot}/node_modules/*",
31+
"webpack:///*": "${webRoot}/*"
32+
}
33+
}
34+
],
35+
"compounds": [
36+
{
37+
"name": "BostNote All",
38+
"configurations": ["BoostNote Main", "BoostNote Renderer"]
39+
}
40+
]
41+
}

.vscode/tasks.json

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{
2+
// See https://go.microsoft.com/fwlink/?LinkId=733558
3+
// for the documentation about the tasks.json format
4+
"version": "2.0.0",
5+
"tasks": [
6+
{
7+
"label": "Build Boostnote",
8+
"group": "build",
9+
"type": "npm",
10+
"script": "watch",
11+
"isBackground": true,
12+
"presentation": {
13+
"reveal": "always",
14+
},
15+
"problemMatcher": {
16+
"pattern":[
17+
{
18+
"regexp": "^([^\\\\s].*)\\\\((\\\\d+,\\\\d+)\\\\):\\\\s*(.*)$",
19+
"file": 1,
20+
"location": 2,
21+
"message": 3
22+
}
23+
]
24+
}
25+
}
26+
]
27+
}

docs/debug.md

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# How to debug Boostnote (Electron app)
2+
23
This page is also available in [Japanese](https://github.com/BoostIO/Boostnote/blob/master/docs/jp/debug.md), [Korean](https://github.com/BoostIO/Boostnote/blob/master/docs/ko/debug.md), [Russain](https://github.com/BoostIO/Boostnote/blob/master/docs/ru/debug.md), [Simplified Chinese](https://github.com/BoostIO/Boostnote/blob/master/docs/zh_CN/debug.md), [French](https://github.com/BoostIO/Boostnote/blob/master/docs/fr/debug.md) and [German](https://github.com/BoostIO/Boostnote/blob/master/docs/de/debug.md).
34

5+
## Debug with Google Chrome developer Tools
46
Boostnote is an Electron app so it's based on Chromium; developers can use `Developer Tools` just like Google Chrome.
57

68
You can toggle the `Developer Tools` like this:
@@ -11,12 +13,24 @@ The `Developer Tools` will look like this:
1113

1214
When errors occur, the error messages are displayed at the `console`.
1315

14-
## Debugging
16+
### Debugging
1517
For example, you can use the `debugger` to set a breakpoint in the code like this:
1618

1719
![debugger](https://cloud.githubusercontent.com/assets/11307908/24343879/9459efea-127d-11e7-9943-f60bf7f66d4a.png)
1820

1921
This is just an illustrative example, you should find a way to debug which fits your style.
2022

21-
## References
23+
### References
2224
* [Official document of Google Chrome about debugging](https://developer.chrome.com/devtools)
25+
26+
## Debug with Visual Studio Code
27+
28+
1. Install **[Debugger for Chrome](https://marketplace.visualstudio.com/items?itemName=msjsdiag.debugger-for-chrome "Install Debugger for Chrome")** plugin for Visual Studio Code. Then restart it.
29+
2. Pressing **Shift+Command+B** or running **Run Build Task** from the global **Terminal** menu, then pick the task named **Build Boostnote**. Or run `yarn run watch` from the terminal.
30+
3. When above task is running, open **Debug view** in **Activity Bar** on the side of VS Code or use shortcut **Shift+Command+D**.
31+
4. Select the configuration named **Boostnote All** from the **Debug configuration**, then click the green arrow button or press **F5** to start debugging.
32+
5. Now you should find **Boostnote** is running. You will see two processes running, one named **Boostnote Main** and the other named **Boostnote Renderer**. Now you can set **debug breakpoints** in vscode. If you find your **breakpoints** is unverified, you need to switch to the appropriate process between **Boostnote Renderer** and **Boostnote Main**.
33+
34+
### References
35+
* [Electron application debugging](https://electronjs.org/docs/tutorial/application-debugging)
36+
* [Debugger for Chrome](https://marketplace.visualstudio.com/items?itemName=msjsdiag.debugger-for-chrome)

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@
1212
"jest": "jest",
1313
"fix": "eslint . --fix",
1414
"lint": "eslint .",
15-
"dev": "node dev-scripts/dev.js"
15+
"dev": "node dev-scripts/dev.js",
16+
"watch": "webpack-dev-server --hot"
1617
},
1718
"config": {
1819
"electron-version": "3.0.3"

webpack.config.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,14 @@ var config = Object.assign({}, skeleton, {
2828
publicPath: 'http://localhost:8080/assets/'
2929
},
3030
debug: true,
31-
devtool: 'cheap-module-eval-source-map'
31+
devtool: 'cheap-module-eval-source-map',
32+
devServer: {
33+
port: 8080,
34+
hot: true,
35+
inline: true,
36+
quiet: false,
37+
publicPath: 'http://localhost:8080/assets/'
38+
}
3239
})
3340

3441
module.exports = config

0 commit comments

Comments
 (0)