Add VSCode debug config

This commit is contained in:
Vendicated 2022-11-09 19:26:39 +01:00
parent 3b65384b94
commit 3c8084ec36
No known key found for this signature in database
GPG key ID: EC781ADFB93EFFA3
3 changed files with 55 additions and 7 deletions

View file

@ -1,3 +1,11 @@
{ {
"recommendations": [ "EditorConfig.EditorConfig" ] "recommendations": [
"EditorConfig.EditorConfig",
"pmneo.tsimporter",
"dbaeumer.vscode-eslint",
"formulahendry.auto-rename-tag",
"GregorBiswanger.json2ts",
"eamodio.gitlens",
"kamikillerto.vscode-colorize"
]
} }

37
.vscode/launch.json vendored Normal file
View file

@ -0,0 +1,37 @@
{
// this allows you to debug Vencord from VSCode.
// How to use:
// You need to run Discord via the command line to pass some flags to it.
// If you want to debug the main (node.js) process (preload.ts, ipcMain/*, patcher.ts),
// add the --inspect flag
// To debug the renderer (99% of Vencord), add the --remote-debugging-port=9223 flag
//
// Now launch the desired configuration in VSCode and start Discord with the flags.
// For example, to debug both process, run Electron: All then launch Discord with
// discord --remote-debugging-port=9223 --inspect
"version": "0.2.0",
"configurations": [
{
"name": "Electron: Main",
"type": "node",
"request": "attach",
"port": 9229,
"timeout": 30000
},
{
"name": "Electron: Renderer",
"type": "chrome",
"request": "attach",
"port": 9223,
"timeout": 30000,
"webRoot": "${workspaceFolder}/src"
}
],
"compounds": [
{
"name": "Electron: All",
"configurations": ["Electron: Main", "Electron: Renderer"]
}
]
}

View file

@ -44,20 +44,23 @@ const nodeCommonOpts = {
define: defines, define: defines,
}; };
const sourceMapFooter = s => watch ? "" : `//# sourceMappingURL=vencord://${s}.js.map`;
const sourcemap = watch ? "inline" : "external";
await Promise.all([ await Promise.all([
esbuild.build({ esbuild.build({
...nodeCommonOpts, ...nodeCommonOpts,
entryPoints: ["src/preload.ts"], entryPoints: ["src/preload.ts"],
outfile: "dist/preload.js", outfile: "dist/preload.js",
footer: { js: "//# sourceURL=VencordPreload\n//# sourceMappingURL=vencord://preload.js.map" }, footer: { js: "//# sourceURL=VencordPreload\n" + sourceMapFooter("preload") },
sourcemap: "external", sourcemap,
}), }),
esbuild.build({ esbuild.build({
...nodeCommonOpts, ...nodeCommonOpts,
entryPoints: ["src/patcher.ts"], entryPoints: ["src/patcher.ts"],
outfile: "dist/patcher.js", outfile: "dist/patcher.js",
footer: { js: "//# sourceURL=VencordPatcher\n//# sourceMappingURL=vencord://patcher.js.map" }, footer: { js: "//# sourceURL=VencordPatcher\n" + sourceMapFooter("patcher") },
sourcemap: "external", sourcemap,
}), }),
esbuild.build({ esbuild.build({
...commonOpts, ...commonOpts,
@ -65,9 +68,9 @@ await Promise.all([
outfile: "dist/renderer.js", outfile: "dist/renderer.js",
format: "iife", format: "iife",
target: ["esnext"], target: ["esnext"],
footer: { js: "//# sourceURL=VencordRenderer\n//# sourceMappingURL=vencord://renderer.js.map" }, footer: { js: "//# sourceURL=VencordRenderer\n" + sourceMapFooter("renderer") },
globalName: "Vencord", globalName: "Vencord",
sourcemap: "external", sourcemap,
plugins: [ plugins: [
globPlugins, globPlugins,
...commonOpts.plugins ...commonOpts.plugins