Static Javascript files in Phoenix 1.4
Phoenix 1.4 has been released and uses Webpack etc for managing assets instead of Brunch.
To use local, static, javascript files without npm and webpack you can do the following:
1) put your js files in the directory: assets/static
2) add the file names to the Plug.static section in the file: endpoint.ex
eg)
plug Plug.Static,
at: "/",
from: :myapp,
gzip: false,
only: ~w(css fonts images js favicon.ico robots.txt jquery.min.js vuedist.js)
3) import your js file in the templates/layout/app.html.eex.
eg)
<script type="text/javascript" src="<%= Routes.static_path(@conn, "/jquery.min.js") %>"></script>
That should be it.
On a related note, the article below takes a look at why your node_modules directory is so ridiculously large “out of the box”.
Links: