0

I am currently using Visual Code Studio and I have Live Server and Debugger for Chrome extensions installed.

I am testing a simple .html file to see how the debug is working on VS Code as I am newly switching to.

enter image description here

I changed the url to "url": "http://localhost:5500" in launch.json file to use the Live Server port.

Now the issue : when I click go live, the browser opens http://127.0.0.1:5500/debug.html but when I click F5 to debug I am redirected only to http://127.0.0.1:5500. Is there a way to redirect to full path in debug mode instead of adjusting the url manually each time to http://127.0.0.1:5500/'File Path' ? and if it's possible the page will be opened in new tab not new chrome window.

enter image description here

Any suggestions please what am I missing in my setup ? I followed multiple threads and documentations but still can't make it work, example this and this.

DevTN
  • 511
  • 2
  • 9
  • 35

1 Answers1

1

Maybe you should define the .html file.

Here is an example:

{
    "port": 8181,
    "host": "0.0.0.0",
    "root": "/public",
    "open": false,
    "ignore": "scss,my/templates",
    "file": "index.html",
    "wait": 1000,
    "mount": [
        ["/components", "./node_modules"],
        ["/image", "./myImageFolder"]
    ],
    "logLevel": 2
}

I hope that helps! Please let me know if there is anything else, I can help you with.

georgekrax
  • 1,065
  • 1
  • 11
  • 22
  • that's the live server config file. i was making some googling and it looks like to set up the rule on launch.json on the debug side. I am not sure about your approach how i should update my settings based on your recommendation – DevTN Apr 20 '20 at 20:04
  • In the `.json` file, add a key with the name `"file"` and assign the value of `"index.html"`. – georgekrax Apr 20 '20 at 20:08
  • I am doing it that way. but i want it to detect dynamically the name of file instead of writting it by myself manually each time. instead of using "file":"login.html" or "file":"datatable.html"... it will be sth like "file":"{my_current_file_in_debug}" – DevTN Apr 21 '20 at 07:30
  • Check out variables in the Visual Studio Code (https://code.visualstudio.com/docs/editor/variables-reference). I think for your case that would be `${file}`. – georgekrax Apr 21 '20 at 07:48