Skip to content

add wisp dev server#602

Draft
graphiteisaac wants to merge 3 commits intogleam-lang:mainfrom
graphiteisaac:dev-server
Draft

add wisp dev server#602
graphiteisaac wants to merge 3 commits intogleam-lang:mainfrom
graphiteisaac:dev-server

Conversation

@graphiteisaac
Copy link
Member

Cheerio!

With the new watchexec package, running a wisp server and auto-rebuilding the site is a breeze, so I thought it was time to tap into the Gleam ecosystem for this, instead of using my currently very cursed local setup. Feels so nice to just run gleam dev and not think about it again.

I've gone to some level of thought (as far as my peanut brain can go, anyway) for static assets, so we don't have to rebuild the entire website every time a single line of CSS is changed, for example.

With the new watchexec package, running a wisp server and
auto-rebuilding the site is a breeze, so I thought it was time to tap
into the Gleam ecosystem for this.

fn rebuild_assets(changed_paths: List(String)) {
list.each(changed_paths, fn(path) {
let dest = string.replace(path, each: "/priv", with: "/dist")
Copy link
Member

Choose a reason for hiding this comment

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

This could do weird stuff if someone has a highler level /priv* directory. Can we strip the current working directory from the path instead? 🙏

Something like this maybe

fn rebuild_assets(cwd: String, changed_paths: List(String)) {
  list.each(changed_paths, fn(path) {
    let assert Ok(#("", shortened_path)) = string.split_once(path, cwd <> "/priv")
      as { path <> " not within priv dir" }
    // ...

@graphiteisaac
Copy link
Member Author

Great call on the working dir, decided to just directly call out to Erlang instead of bringing in a whole new dependency just for one function

@graphiteisaac
Copy link
Member Author

Turns out I'm not the sharpest tool in the shed and this needs more work. Just simply running website.build_site inside the dev process actually just reruns the old code, so changes don't show up. Will require either some looking into OTP hot code replacement or cheesing it with shellout, I think.

@graphiteisaac graphiteisaac marked this pull request as draft March 6, 2026 02:35
@lpil
Copy link
Member

lpil commented Mar 9, 2026

We could just run gleam run in the shell again perhaps

@graphiteisaac
Copy link
Member Author

We could just run gleam run in the shell again perhaps

Yeah, I've done this in my local branch but it really feels not-so-good. I'd really like to come up with a smarter solution, honestly.

@lpil
Copy link
Member

lpil commented Mar 15, 2026

wdym doesn't feel good? Not any way around needing to recompile code when it changes.

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.

2 participants