-
Notifications
You must be signed in to change notification settings - Fork 158
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove root parameter override in watch mode #925
base: main
Are you sure you want to change the base?
Changes from all commits
112b921
dfa48cc
6cd58b9
22f4feb
6e67326
f9ac119
aa0ea07
0dcda55
61ed808
2df3a2c
f1fd7b3
6a313ab
d2e196c
4700b62
86296aa
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -792,11 +792,11 @@ module Serve = | |
let refreshEvent = FSharp.Control.Event<string>() | ||
|
||
/// generate the script to inject into html to enable hot reload during development | ||
let generateWatchScript (port: int) = | ||
let tag = | ||
""" | ||
let generateWatchScript = | ||
""" | ||
<script type="text/javascript"> | ||
var wsUri = "ws://localhost:{{PORT}}/websocket"; | ||
var loc = window.location.valueOf(); | ||
var wsUri = `${loc.protocol.replace("http", "ws")}//${loc.host}/websocket`; | ||
function init() | ||
{ | ||
websocket = new WebSocket(wsUri); | ||
|
@@ -823,8 +823,6 @@ module Serve = | |
</script> | ||
""" | ||
|
||
tag.Replace("{{PORT}}", string<int> port) | ||
|
||
let connectedClients = ConcurrentDictionary<WebSocket, unit>() | ||
|
||
let socketHandler (webSocket: WebSocket) (context: HttpContext) = | ||
|
@@ -1406,10 +1404,13 @@ type CoreBuildOptions(watch) = | |
// Adjust the user substitutions for 'watch' mode root | ||
let userRoot, userParameters = | ||
if watch then | ||
let userRoot = sprintf "http://localhost:%d/" this.port_option | ||
let userRoot = | ||
match this.static_content_host_option with | ||
| Some s -> sprintf "%O" s | ||
| _ -> sprintf "http://localhost:%d/" this.port_option | ||
|
||
if userParametersDict.ContainsKey(ParamKeys.root) then | ||
printfn "ignoring user-specified root since in watch mode, root = %s" userRoot | ||
printfn "ignoring user-specified root since in watch mode, root = '%s'" userRoot | ||
|
||
let userParameters = | ||
[ ParamKeys.root, userRoot ] | ||
|
@@ -1667,7 +1668,7 @@ type CoreBuildOptions(watch) = | |
let getLatestWatchScript () = | ||
if watch then | ||
// if running in watch mode, inject hot reload script | ||
[ ParamKeys.``fsdocs-watch-script``, Serve.generateWatchScript this.port_option ] | ||
[ ParamKeys.``fsdocs-watch-script``, Serve.generateWatchScript ] | ||
else | ||
// otherwise, inject empty replacement string | ||
[ ParamKeys.``fsdocs-watch-script``, "" ] | ||
|
@@ -2088,6 +2089,9 @@ type CoreBuildOptions(watch) = | |
abstract port_option: int | ||
default x.port_option = 0 | ||
|
||
abstract static_content_host_option: Uri option | ||
default x.static_content_host_option = None | ||
|
||
[<Verb("build", HelpText = "build the documentation for a solution based on content and defaults")>] | ||
type BuildCommand() = | ||
inherit CoreBuildOptions(false) | ||
|
@@ -2115,3 +2119,15 @@ type WatchCommand() = | |
|
||
[<Option("port", Required = false, Default = 8901, HelpText = "Port to serve content for http://localhost serving.")>] | ||
member val port = 8901 with get, set | ||
|
||
[<Option("contenturlroot", | ||
Required = false, | ||
HelpText = | ||
"Optional URL root 'http[s]://<host>[:<port>]' to use in static content for browsers not running on localhost.")>] | ||
member val contenturlroot = "" with get, set | ||
|
||
override x.static_content_host_option = | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for the tip with Though the output is quite verbose with results from the other projects. It also seems to create diffs in the |
||
if not (String.IsNullOrEmpty x.contenturlroot) then | ||
x.contenturlroot |> Uri |> Some | ||
else | ||
None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would
work for you here?
I believe it can be an easy way to make
work and would be the least disruptive for now.
We don't feel good enough about the new setting.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will test and let you know! Thanks for talking it through!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure thing, thanks for your patience!