Make elixir app recompile and reload on source code change

前端 未结 4 902
逝去的感伤
逝去的感伤 2021-02-12 04:07

How to automatically recompile and reload my iex + mix application every time I modify the source code?

If there\'s no way for iex + mix combination to do that, what\'s

4条回答
  •  无人共我
    2021-02-12 04:18

    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!

提交回复
热议问题