You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<description>This guide will walk through setting up a Phoenix project with Elixirscript. This guide assumes you have already created a Phoenix project
21
-
NOTE: This guide covers Phoenix 1.2. It will be updated when Phoenix 1.3 is released
21
+
Update: 2017-08-15: This guide has been updated to cover both ElixirScript 0.30 and Phoenix 1.3
22
22
Update your mix.exs file to add the current version of elixirscript to your dependencies:
23
-
defp deps do [ #other deps {:elixir_script, &quot;~&gt; x.x.x&quot;} ] Run mix deps.get:
23
+
defp deps do [ #other deps {:elixir_script, &quot;~&gt; x.x&quot;} ] Run mix deps.get:
24
24
mix deps.get Next, Add the elixir_script compiler to your list of mix compilers.</description>
<p>Elixirscript by default will looks for input in the <code>lib/elixirscript</code> directory. It will also by default output to <code>priv/elixirscript</code>. Update the input directory to <code>web/static/elixirscript</code>. Update the output directory to <code>web/static/js/build</code>. This lets it tie into Brunch’s pipeline.</p>
83
+
<p>Make the <code>input</code> the entry point module of your ElixirScript App. Here is will be <code>MyApp.App</code> which we will
84
+
define later. Next, add the <code>output</code> to the configuration and make it <code>"assets/js/build"</code>. By default the output
85
+
goes to <code>priv/elixir_script/build</code>, but we want to place our output somewhere that our asset compilation process can pick it up and bundle it with any other JavaScript.</p>
84
86
85
-
<p>Next, update the watcher configuration to use the Elixirscript watcher:</p>
87
+
<p>Create <code>app.ex</code> in the <code>lib/my_app_frontend</code> directory</p>
<p>For this example, write a simple module that will write <code>Hello, world</code> to the console on start:</p>
99
93
100
-
<pre><codeclass="language-elixir">defmodule App do
94
+
<pre><codeclass="language-elixir">defmodule MyApp.App do
101
95
102
96
def start(_type, _args) do
103
-
:console.log("Hello, world")
97
+
IO.puts("Hello, world")
104
98
end
105
99
106
100
end
107
101
</code></pre>
108
102
109
-
<p>Finally, update <code>web/static/js/app.js</code> to start your Elixirscript app:</p>
103
+
<p>Finally, update <code>assets/js/app.js</code> to start your Elixirscript app:</p>
110
104
111
-
<pre><codeclass="language-javascript">import Elixir from './build/Elixir.App';
112
-
Elixir.start(Elixir.App, [])
105
+
<pre><codeclass="language-javascript">import Elixir from './build/elixirscript.build.js';
106
+
Elixir.start(Elixir.MyApp.App, [])
113
107
</code></pre>
114
108
115
109
<p>The empty array is list of initial arguments for your app.</p>
116
110
117
-
<p>If you run <code>mix compile</code>, you should see a JavaScript file, <code>Elixir.App.js</code> in your <code>web/static/js/build</code> directory.</p>
111
+
<p>If you run <code>mix compile</code>, you should see a JavaScript file, <code>elixirscript.build.js</code> in your <code>assets/js/build</code> directory.</p>
118
112
119
-
<p>If you run <code>mix phoenix.server</code>, open your browser, and then open your console, you should see <code>Hello, world</code>. Any changes should cause a reload</p>
113
+
<p>If you run <code>mix phx.server</code>, open your browser, and then open your console, you should see <code>Hello, world</code>. Any changes should cause a recompilation of your ElixirScript code and a reload of the browser</p>
120
114
121
115
</div>
122
116
</div>
@@ -126,13 +120,13 @@ <h1 class="title">using with phoenix</h1>
ElixirScript 0.30 is a large release with lots of changes. It includes a rewrite of the compiler, a change in JavaScript interoperability and much more. This is also the first version to require Erlang 20 and Elixir 1.5, compiled with Erlang 20. ElixirScript can compile your Elixir code and dependencies into JavaScript, with some limitations. These changes make this the best release of ElixirScript so far! This is a great point to give ElixirScript a try for yourself. ...
<description>ElixirScript 0.30 is a large release with lots of changes. It includes a rewrite of the compiler, a change in JavaScript interoperability and much more. This is also the first version to require Erlang 20 and Elixir 1.5, compiled with Erlang 20. ElixirScript can compile your Elixir code and dependencies into JavaScript, with some limitations. These changes make this the best release of ElixirScript so far! This is a great point to give ElixirScript a try for yourself.</description>
<description>This guide will walk through setting up a Phoenix project with Elixirscript. This guide assumes you have already created a Phoenix project
44
-
NOTE: This guide covers Phoenix 1.2. It will be updated when Phoenix 1.3 is released
53
+
Update: 2017-08-15: This guide has been updated to cover both ElixirScript 0.30 and Phoenix 1.3
45
54
Update your mix.exs file to add the current version of elixirscript to your dependencies:
46
-
defp deps do [ #other deps {:elixir_script, &quot;~&gt; x.x.x&quot;} ] Run mix deps.get:
55
+
defp deps do [ #other deps {:elixir_script, &quot;~&gt; x.x&quot;} ] Run mix deps.get:
47
56
mix deps.get Next, Add the elixir_script compiler to your list of mix compilers.</description>
0 commit comments