vscode-preview-server
vscode-preview-server copied to clipboard
Request user setting for server root.
I suggest being able to alter the default location of one's server root.
For example,
- I have the following folder loaded in Visual Studio Code: C:\Users\John\Documents\Sda\Code\Php
- I'm working on C:\Users\John\Documents\Sda\Code\Php\Examples\helloWorld.php. That is, from the root of the current folder \Examples\helloWorld.php.
- Under current vscode-preview-server behaviour I run "Launch on default browser" and http://localhost:8080/Examples/helloWorld.php is sent to my browser. However, this produces a 404 error. Due to personal preferences in how I've set up my server environment my root web server doesn't match, "C:\Users\John\Documents\Sda\Code\Php". I need the resulting URL to return "http://localhost:8080/php/Examples/helloWorld.php"
So I'd like user setting to use like ....
previewServer.serverRootLocalPath = "C:\Users\John\Documents\Sda\Code"
and for vscode-preview-server to work out that given the current file I'm working on ....
C:\Users\John\Documents\Sda\Code\Php\Examples\helloWorld.php
... the difference between the two is ...
Php\Examples\helloWorld.php
... and it is that which needs to be appended to my server string "http://localhost:8080/" (with slash fixing) for ...
http://localhost:8080/php/Examples/helloWorld.php
Sorry for my delay. Can you resolve this in below setting?
"previewServer.proxy": "localhost:8080/Php/Examples/helloWorld.php"
No worries about the delay ... we are both taking our time :)
Yes that effects being able to work on helloWorld.php
, with saved changes in the editor being automatically updated in the browser.
Of course that doesn't help when I work on on a different file in C:\Users\John\Documents\Sda\Code\Php
.
If I can find the time I'd be keen to help out and have a go at the code myself. However, I'm unlikely to find the time for the next 2 months.
I see. PRs welcomed.
Related: this extension cannot figure out what folder to serve when using a VS Code workspace. It always defaults to the project folder of the first project. I'm posting this here because the solution for the stated problem needs to address both issues.
@jmussman I move issue to #21
"Preview on side panel"(1) and "Launch on browser"(2) don't seem to resolve to the same root directory.
Suppose a file as C:\\foo\\bar\\www.html
:
- when I set workspace folder path to
C:\\foo\\bar
, I can do (1) but (2) resolves toC:\\foo\\www.html
which doesn't exist. - when I set workspace folder path to
C:\\foo
, I can do (2) but (1) resolves toC:\\foo\\www.html
which doesn't exist.
I'm working on Apache set with XAMPP in Windows 10.