Hot reload for Elm application #6
Loading…
Reference in a new issue
No description provided.
Delete branch "nix-frontend-hot-reload"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Currently there are no setup for Elm application to reflect changes in the browser without killing the server and restarting for each change. This PR adds
elm-go
to Nix setup which enables live reloads.But comes with few caveats
8000
(different from rust backend running at port8080
)make serve DEBUG=1
The is not ideal as web sockets and any communication with backend fails due to port mismatch. This can be solved by adding a reverse proxy (like Caddy) that maps
localhost:8000
tolocalhost:8080
but this entail bringing in additional setup complexity in Nix which we can avoid for now.One more thing, we can always use refresh the page while working on port
8080
page (backend enabled).@ -116,0 +121,4 @@
if [ ! -d "$PWD/frontend/node_modules/elm-go" ]; then
echo "Installing elm-go..."
cd "$PWD/frontend"
${nodejs_22}/bin/npm install elm-go
So you're technically not supposed to install things inside nix build files that require internet access. To fix this, we should either use elmPackages.elm-live or have @Artturin package up the elm-live fork, elm-go.
I will add
elmPackages.elm-live
This is a
mkShell
shellHook
, which runs commands outside the build sandbox so using the internet is fine but running a package managers install commands is still unhygienic.Here's a patch adding elm-go which can then be used with
pkgs.elm-go
@Artturin Thanks
The port can be changed with
EXAMPLE_ELM_APP_PORT
env var if needed.Looks good to me! Merging now!