Skip to content

Comments

support multiple perferred server roots (#476)#581

Open
lixvbnet wants to merge 1 commit intomicrosoft:mainfrom
lixvbnet:main
Open

support multiple perferred server roots (#476)#581
lixvbnet wants to merge 1 commit intomicrosoft:mainfrom
lixvbnet:main

Conversation

@lixvbnet
Copy link

@lixvbnet lixvbnet commented Dec 12, 2023

This PR is to resolve #476


To go beyond #155, it would be nice if we can set multiple preferred server roots as one string, just like how we set PATH variable.

  • /path/to/root1:/path/to/root2:/path/to/root3
  • /dist:/build:/output:/publish
  • nice to support "." too, which stands for the folder where the open file is located

If none of the directories exists, it defaults to the workspace root.

@lixvbnet
Copy link
Author

@microsoft-github-policy-service agree

Copy link
Contributor

@andreamah andreamah left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for looking into this! Thinking about it more, I would probably prefer a setting that can take an array or string (instead of just parsing the string from within the extension). For example, the npm.exclude setting that is built into VS Code has this:
https://github.com/microsoft/vscode/blob/93b691ea016f4ee8dc8d2edfde9f897fb733445e/extensions/npm/package.json#L255-L258
This way, it is more consistent with what we have in other extensions.

@lixvbnet
Copy link
Author

Fair point. Just updated the commit.

@andreamah
Copy link
Contributor

One more thing: could you update the setting to specify what the array value would describe (ie: precedence and first is highest)?

@lixvbnet
Copy link
Author

lixvbnet commented Dec 15, 2023

Sure, will do. (Edit: Done. updated the commit.)

Just found another glitch while playing around with current branch. It sometimes doesn't work as expected, because the server seems to have caching that it doesn't always respect the root value returned from the utility function.

For example, with "serverRoot" set to ["/dist", "/publish"] and there's an "index.html" file inside each folder.

  1. Preview dist/index.html
  2. Preview publish/index.html

Step 2 will still be previewing the content of dist/index.html same with step 1, unless I stop the server and preview again.

Having similar issue with ".", as its resolved value is always changing while switching among different files.

Do you have any idea on this?
If there's no easy fix, or it's an expected behavior, then this PR has to be dropped, I think, to avoid bringing confusion.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature request] Allow setting multiple preferred Server Roots as one string

2 participants