Elixir + Gleam = ❤️
A tiny hex package makes it easier to use gleam in elixir and phoenix projects
This package does two things
- Runs the gleam compiler
- In development it automatically reloads the gleam files when recompiled
Demo with Phoenix Live Reload
Note: Make sure gleam is already installed on your system.
This package is available on hex.
-
The package can be installed by adding
gleam_compile
to your list of dependencies inmix.exs
:def deps do [ {:gleam_compile, "~> 0.2.0"} ] end
-
Add
:gleam
to list of compilers, and the gleam folders to theerlc_paths
in yourmix.exs
def project do [ app: :jib, version: "0.1.0", elixir: "~> 1.5", elixirc_paths: elixirc_paths(Mix.env()), + erlc_paths: ["src", "gen"], + compilers: [:gleam] ++ Mix.compilers(), start_permanent: Mix.env() == :prod, releases: releases(), aliases: aliases(), deps: deps() ] end
-
Add
:gleam
to list of compilers in yourmix.exs
compilers: [:phoenix, :gettext, :gleam] ++ Mix.compilers()
def project do [ app: :jib, version: "0.1.0", elixir: "~> 1.5", elixirc_paths: elixirc_paths(Mix.env()), erlc_paths: ["src", "gen"], - compilers: [:phoenix, :gettext] ++ Mix.compilers(), + compilers: [:phoenix, :gettext, :gleam] ++ Mix.compilers(), start_permanent: Mix.env() == :prod, releases: releases(), aliases: aliases(), deps: deps() ] end
-
In
dev.exs
add this line in theEndpoint
configreloadable_compilers: [:gettext, :phoenix, :elixir, :gleam],
config :my_app, MyAppWeb.Endpoint, http: [port: 4000], debug_errors: true, code_reloader: true, check_origin: false, + reloadable_compilers: [:gettext, :phoenix, :elixir, :gleam], watchers: [ node: [ "node_modules/webpack/bin/webpack.js", "--mode", "development", "--watch-stdin", cd: Path.expand("../assets", __DIR__) ] ]
-
Add gleam files to the live_reload patterns
~r"src/.*(gleam)$",
config :my_app, MyAppWeb.Endpoint, live_reload: [ patterns: [ ~r"priv/static/.*(js|css|png|jpeg|jpg|gif|svg)$", ~r"priv/gettext/.*(po)$", + ~r"src/.*(gleam)$", ~r"lib/jib_web/{live,views}/.*(ex)$", ~r"lib/jib_web/templates/.*(eex)$" ] ]
- Mixing Gleam & Elixir – by Michael Jones
- Louis (creator of gleam) for talking me through the process and helping with debugging
GleamCompile is released under the Apache License 2.0 - see the LICENSE file.