Skip to content

Commit e4989d8

Browse files
committed
Automatically recompile and reload Elixir code
1 parent 9eab58d commit e4989d8

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

.iex.exs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,8 @@
22
# their custom IEx configuration on top of project-specific configurations.
33
import_file_if_available("~/.iex.exs")
44

5+
# Automatically reload code changes after code has been recompiled.
6+
# Combine this with Mise task `watch-compile` to automatically recompile code when a file changes.
7+
IEx.configure(auto_reload: true)
8+
59
# Add project-specific configuration here...

mise.toml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
[tools]
22
erlang = "28.2"
33
elixir = "1.19.4-otp-28"
4+
# Watch for file changes
5+
watchexec = "2.3.2"
46

57
[settings]
68
# Hooks are experimental
@@ -30,6 +32,12 @@ postinstall = """
3032
mix local.rebar --force --if-missing
3133
"""
3234

35+
36+
[tasks.watch-compile]
37+
description = "Automatically recompile Elixir code when Elixir files change"
38+
# It runs at most once every 5 seconds, and restarts if it's still running
39+
run = "watchexec --debounce 5sec --restart --clear --exts 'ex,exs' -- mix compile --force"
40+
3341
[tasks.docker-compose-up]
3442
description = "Start Docker Compose services, waiting for them to be healthy before exiting"
3543
run = "docker compose up --wait"

0 commit comments

Comments
 (0)