Hi
I use webpack to bundle up my clientside application, which I place inside the priv/static folder as part of my build script. I then route to these based on the subdomain from which they were requested.
Without using hashes in the filenames, I was doing something like
defmodule MyApp.PageController do
use MyApp.Web, :controller
def landing(conn, _params) do
conn
|> put_headers
|> render_entry("landing.html")
end
def app(conn, _params) do
conn
|> put_headers
|> render_entry("index.html")
end
defp put_headers(conn) do
conn |> put_resp_header("content-type", "text/html; charset=utf-8")
end
defp render_entry(conn, file) do
path = resolve(file)
conn |> Plug.Conn.send_file(200, path)
end
defp resolve(file) do
"./priv/static/#{file}"
end
end
But I am not sure how this will be possible when the filenames are not known upfront. I suppose you could pattern match on the filenames in the static folder, but this does not seem very efficient.
Any suggestions?