vscode-preview-server icon indicating copy to clipboard operation
vscode-preview-server copied to clipboard

Request user setting for server root.

Open JohnLukeBentley opened this issue 7 years ago • 6 comments

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

JohnLukeBentley avatar Oct 14 '17 06:10 JohnLukeBentley

Sorry for my delay. Can you resolve this in below setting?

"previewServer.proxy": "localhost:8080/Php/Examples/helloWorld.php"

YuichiNukiyama avatar Oct 29 '17 06:10 YuichiNukiyama

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.

JohnLukeBentley avatar Oct 31 '17 10:10 JohnLukeBentley

I see. PRs welcomed.

YuichiNukiyama avatar Nov 05 '17 06:11 YuichiNukiyama

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 avatar Dec 22 '17 17:12 jmussman

@jmussman I move issue to #21

YuichiNukiyama avatar Dec 24 '17 06:12 YuichiNukiyama

"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 to C:\\foo\\www.html which doesn't exist.
  • when I set workspace folder path to C:\\foo, I can do (2) but (1) resolves to C:\\foo\\www.html which doesn't exist.
    I'm working on Apache set with XAMPP in Windows 10.

yuxiang-zhang avatar Feb 28 '19 20:02 yuxiang-zhang