Today I (finally) found a way to make it possible to debug JavaScript code of extensions using VS Code! 🎉
Developers, consider this as a (late) Xmas gift ! 🎁
To do that I had to write a small vscode extension that allows me to get the package name from composer.json
. Without that, the .vscode/launch.json
configuration file would not be generic and directly compatible with all extensions.
Here is how I have set it up (using Firefox):
.vscode/launch.json
{
"version": "0.2.0",
"configurations": [
{
"name": "Attach to Flarum",
"type": "firefox",
"request": "attach",
"url": "http://localhost:8888",
"pathMappings": [
{
"url": "webpack://${command:glowingblue-composer-package-name.getName}/src/",
"path": "${workspaceFolder}/js/src/"
}
]
}
]
}
(You most certainly need to use a different URL parameter in your configuration)
Required vscode extensions
Debugging in Firefox
To be able to debug in Firefox, follow the attach instructions of the firefox-devtools.vscode-firefox-debug
vscode extension.
I guess it must be possible to set this all up for Chrome as well, but I haven't test it.
Debug flarum/core
(and extensions from the vendor
directory that you haven't opened in a dedicated vscode workspace)
See post below.