vscode-firefox-debug icon indicating copy to clipboard operation
vscode-firefox-debug copied to clipboard

Path mappings not working with Python/Django project

Open knieselpriem opened this issue 5 years ago • 0 comments

regards to: Debugger for FireFox v2.9.1

With Python/Django a URL maps to a path in an "app" folder. The HTML code is generated by Jinja2 template engine. I included a JS file into a Jinja2 template file:

{% block javascript %}
<script src="{{ static('assets\plugins\custom\leaflet\leaflet.bundle.js') }}"></script>
<script type="text/javascript">
{% include "map/js/map.js" %}
</script>
{% endblock javascript %}

The static JS files assets\plugins\custom\leaflet\leaflet.bundle.js is found by "vscode-firefox-debug", but the included JS file map/js/map.js is not. The path structure is as followed:

${workspaceFolder}
|-- www
|    |-- jinja
|          |-- map
|               |-- js
|                    |-- map.js
|-- static
     |-- assets
           |-- plugins
                |-- custom
                     |-- leaflet
                          |-- leaflet.bundle.js

The URL http://127.0.0.1:8000/map is mapped in the Django project to the path ${workspaceFolder}\\www\\jinja\\map and is working (shows the website).

The problem is, that the mapping with ${workspaceFolder}\\.vscode\\launch.json is not working. My configuration is as followed:

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Python: Django",
            "type": "python",
            "request": "launch",
            "program": "${workspaceFolder}\\manage.py",
            "args": [
                "runserver",
                "--noreload"
            ],
            "django": true
        },
        {
            "name": "JS",
            "type": "firefox",
            "firefoxExecutable": "D:\\Tools\\FirefoxPortable\\FirefoxPortable.exe",
            "request": "launch",
            "reAttach": true,
            "url": "http://127.0.0.1:8000/",
            "webRoot": "${workspaceFolder}",
            "pathMappings": [
                {
                    "url": "http://127.0.0.1:8000/map/(index)",
                    "path": "${workspaceFolder}\\www\\jinja\\map\\js\\map.js"
                },
            ],
            "skipFiles": [
                "${workspaceFolder}\\static\\**\\*.js"
            ],
            "log": {
                "consoleLevel": {
                    "PathConversion": "Debug",
                    "default": "Error"
                }
            }
        }
    ]
}

I also tried different paths, e.g. ${workspaceFolder}\\www\\jinja\\map\\js or ${workspaceFolder}\\www\\jinja\\map, and even ${workspaceFolder}\\www\\jinja\\map\\js\\index.html with a dummy HTML file as workaround, which includes only the JS file. But in the status window for the debugger appears not the correct mapping, but ${workspaceFolder}\\map (as the URL)

Output from Debug Console:

DEBUG|000.121|PathConversion: Converted url http://127.0.0.1:8000/static/assets/js/scripts.bundle.js to path ${workspaceFolder}\static\assets\js\scripts.bundle.js
DEBUG|000.122|PathConversion: Converted url http://127.0.0.1:8000/map/ to path ${workspaceFolder}\map\
DEBUG|000.123|PathConversion: Converted url http://127.0.0.1:8000/static/assets/plugins/custom/leaflet/leaflet.bundle.js to path ${workspaceFolder}\static\assets\plugins\custom\leaflet\leaflet.bundle.js
DEBUG|000.124|PathConversion: Converted url http://127.0.0.1:8000/static/assets/plugins/global/plugins.bundle.js to path ${workspaceFolder}\static\assets\plugins\global\plugins.bundle.js

knieselpriem avatar Jan 20 '21 15:01 knieselpriem