mirror of
https://github.com/marktext/marktext.git
synced 2025-05-02 22:22:18 +08:00
fix: vscode debugging configuration (#889)
This commit is contained in:
parent
4e918503f4
commit
c35395a8f8
11
.editorconfig
Normal file
11
.editorconfig
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
root = true
|
||||||
|
|
||||||
|
# Unix-style newlines with a newline ending every file
|
||||||
|
[*]
|
||||||
|
charset = utf-8
|
||||||
|
trim_trailing_whitespace = true
|
||||||
|
end_of_line = lf
|
||||||
|
insert_final_newline = true
|
||||||
|
indent_style = space
|
||||||
|
indent_size = 2
|
||||||
|
|
@ -73,7 +73,7 @@ function startRenderer () {
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
server.listen(9080)
|
server.listen(9091)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -114,7 +114,12 @@ function startMain () {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function startElectron () {
|
function startElectron () {
|
||||||
electronProcess = spawn(electron, ['--inspect=5858', path.join(__dirname, '../dist/electron/main.js')])
|
electronProcess = spawn(electron, [
|
||||||
|
'--inspect=5861',
|
||||||
|
'--remote-debugging-port=8315',
|
||||||
|
'--nolazy',
|
||||||
|
path.join(__dirname, '../dist/electron/main.js')
|
||||||
|
])
|
||||||
|
|
||||||
electronProcess.stdout.on('data', data => {
|
electronProcess.stdout.on('data', data => {
|
||||||
electronLog(data, 'blue')
|
electronLog(data, 'blue')
|
||||||
|
@ -62,6 +62,11 @@ const mainConfig = {
|
|||||||
target: 'electron-main'
|
target: 'electron-main'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Fix debugger breakpoints
|
||||||
|
if (!proMode && process.env.MARKTEXT_BUILD_VSCODE_DEBUG) {
|
||||||
|
mainConfig.devtool = '#inline-source-map'
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adjust mainConfig for development settings
|
* Adjust mainConfig for development settings
|
||||||
*/
|
*/
|
||||||
|
@ -191,6 +191,11 @@ if (process.env.NODE_ENV !== 'production' && process.env.NODE_ENV !== 'test' &&
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Fix debugger breakpoints
|
||||||
|
if (!proMode && process.env.MARKTEXT_BUILD_VSCODE_DEBUG) {
|
||||||
|
rendererConfig.devtool = '#inline-source-map'
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adjust rendererConfig for production settings
|
* Adjust rendererConfig for production settings
|
||||||
*/
|
*/
|
||||||
|
42
.vscode/launch.json
vendored
42
.vscode/launch.json
vendored
@ -1,35 +1,49 @@
|
|||||||
{
|
{
|
||||||
// Use IntelliSense to learn about possible attributes.
|
|
||||||
// Hover to view descriptions of existing attributes.
|
|
||||||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
|
||||||
"version": "0.2.0",
|
"version": "0.2.0",
|
||||||
"configurations": [
|
"configurations": [
|
||||||
{
|
{
|
||||||
"type": "node",
|
"type": "node",
|
||||||
"request": "launch",
|
"request": "launch",
|
||||||
"name": "Marktext: Main",
|
"name": "Launch Mark Text",
|
||||||
"program": "${workspaceFolder}/.electron-vue/dev-runner.js",
|
"program": "${workspaceFolder}/.electron-vue/dev-runner.js",
|
||||||
"windows": {
|
"env": {
|
||||||
"runtimeExecutable": "${workspaceFolder}/node_modules/.bin/electron.cmd"
|
"NODE_ENV": "development",
|
||||||
}
|
"MARKTEXT_BUILD_VSCODE_DEBUG": "1"
|
||||||
|
},
|
||||||
|
"outFiles": [
|
||||||
|
"${workspaceFolder}/dist/electron/main.js"
|
||||||
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "Marktext: Renderer",
|
"type": "node",
|
||||||
|
"request": "attach",
|
||||||
|
"name": "Attach to Main Process",
|
||||||
|
"port": 5861,
|
||||||
|
"timeout": 60000,
|
||||||
|
"sourceMaps": true,
|
||||||
|
"outFiles": [
|
||||||
|
"${workspaceFolder}/dist/electron/main.js"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Attach to Renderer Process",
|
||||||
"type": "chrome",
|
"type": "chrome",
|
||||||
"request": "attach",
|
"request": "attach",
|
||||||
"port": 8315,
|
"port": 8315,
|
||||||
|
"sourceMaps": true,
|
||||||
"webRoot": "${workspaceFolder}/src",
|
"webRoot": "${workspaceFolder}/src",
|
||||||
"timeout": 30000,
|
"timeout": 60000,
|
||||||
"urlFilter": "localhost:*"
|
"urlFilter": "http://localhost:9091"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"compounds": [
|
"compounds": [
|
||||||
{
|
{
|
||||||
"name": "Marktext: All",
|
"name": "Debug Mark Text",
|
||||||
"configurations": [
|
"configurations": [
|
||||||
"Marktext: Main",
|
"Launch Mark Text",
|
||||||
"Marktext: Renderer"
|
"Attach to Main Process",
|
||||||
|
"Attach to Renderer Process"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
20
.vscode/settings.json
vendored
Executable file
20
.vscode/settings.json
vendored
Executable file
@ -0,0 +1,20 @@
|
|||||||
|
{
|
||||||
|
"editor.insertSpaces": true,
|
||||||
|
"editor.tabSize": 2,
|
||||||
|
"editor.trimAutoWhitespace": true,
|
||||||
|
"files.eol": "\n",
|
||||||
|
"files.insertFinalNewline": true,
|
||||||
|
|
||||||
|
"search.exclude": {
|
||||||
|
"**/.git": true,
|
||||||
|
"**/build": true,
|
||||||
|
"**/node_modules": true,
|
||||||
|
"**/dist": true
|
||||||
|
},
|
||||||
|
"files.watcherExclude": {
|
||||||
|
"**/.git": true,
|
||||||
|
"**/build": true,
|
||||||
|
"**/node_modules": true,
|
||||||
|
"**/dist": true
|
||||||
|
}
|
||||||
|
}
|
13
doc/DEBUGGING.md
Executable file
13
doc/DEBUGGING.md
Executable file
@ -0,0 +1,13 @@
|
|||||||
|
# Debugging
|
||||||
|
|
||||||
|
## Using Visual Studio Code
|
||||||
|
|
||||||
|
The most simplest way is to debug using the `Debug Mark Text` configuration. You can set breakpoints and use the `debugger` statement.
|
||||||
|
|
||||||
|
**Prerequisites:**
|
||||||
|
|
||||||
|
- [Debugger for Chrome](https://marketplace.visualstudio.com/itemdetails?itemName=msjsdiag.debugger-for-chrome)
|
||||||
|
|
||||||
|
## Using Chrome Developer Tools
|
||||||
|
|
||||||
|
You can use the built-in developer tools via `View -> Toggle Developer Tools` in debug mode or connect via `chrome://inspect` using port `5861` for the main process and `8315` for the renderer process (`npm run dev`).
|
@ -18,11 +18,6 @@ class App {
|
|||||||
app.commandLine.appendSwitch('enable-experimental-web-platform-features', 'true')
|
app.commandLine.appendSwitch('enable-experimental-web-platform-features', 'true')
|
||||||
}
|
}
|
||||||
|
|
||||||
// Enable vscode chrome extension debugger connection
|
|
||||||
if (process.env.NODE_ENV === 'development') {
|
|
||||||
app.commandLine.appendSwitch('remote-debugging-port', '8315')
|
|
||||||
}
|
|
||||||
|
|
||||||
app.on('open-file', this.openFile)
|
app.on('open-file', this.openFile)
|
||||||
|
|
||||||
app.on('ready', this.ready)
|
app.on('ready', this.ready)
|
||||||
|
@ -168,7 +168,7 @@ class AppWindow {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const winURL = process.env.NODE_ENV === 'development'
|
const winURL = process.env.NODE_ENV === 'development'
|
||||||
? `http://localhost:9080`
|
? `http://localhost:9091`
|
||||||
: `file://${__dirname}/index.html`
|
: `file://${__dirname}/index.html`
|
||||||
|
|
||||||
win.loadURL(winURL)
|
win.loadURL(winURL)
|
||||||
|
Loading…
Reference in New Issue
Block a user