Using with Phoenix
- In your
mix.exs
, add Elixirscript to you depsdefp deps do [ #other deps {:elixir_script, "~> 0.22.0"} ] end
- In your
mix.exs
, update the compilers key in your project configcompilers: [:phoenix, :gettext, :elixir_script] ++ Mix.compilers
- Also, add the
elixir_script
keyelixir_script: [ input: "web/static/exjs", output: "web/static/js"]]
- In
config/dev.exs
, update thewatchers
config to addelixirscript.watch
watchers: [node: ["node_modules/brunch/bin/brunch", "watch", "--stdin"], mix: ["elixirscript.watch"]]
- Create the folder
web/static/exjs
mkdir web/static/exjs
Now whenever you are running the server in development mode, your exjs
files in web/static/exjs
will be compiled whenever there is a change. The compiled output will end up in web/static/js
. From there, Brunch will compile the JavaScript as usual