Make elixir app recompile and reload on source code change

ぐ巨炮叔叔 提交于 2019-12-03 09:32:58

I think this is what you are looking for: https://github.com/AgilionApps/remix

Currently iex has an internal function to do this:

invoke IEx.Helpers.recompile inside iex console.

Closest thing i know of is in Alchemist for emacs by @tonini. In Alchemist, there's an option to enable

(setq alchemist-hooks-test-on-save t)

which makes it compile and runs tests when you save.

https://github.com/tonini/alchemist.el#testing

For Erlang, I was using "relx -d" together with https://github.com/rustyio/sync The "-d" means that source files are linked using symlinks.

The same works nicely in Elixir. In mix.exs I added :sync in the following two places

  defp deps do
        [{:sync, git: "https://github.com/rustyio/sync.git", tag: "master"}, ....


  def application do
    [applications: [:logger, :sync],

Then, the following command compiles it into a release (before it works, you will have to install hex and exrm).

mix release -dev

Now, when you change a .ex file, and save, it will be recompiled and loaded directly.

19:33:46.474 [info]  ... /apps/testapp1/lib/kv/bucket.ex:0: Recompiled.

You only want sync in your development environment!

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!