Port scripts in Phoenix view into js folder

Hello; I essentially was going to put two scripts in my view like so. However; I am wondering how I would put the first one inside of a module… that is how do you put it in the js/folder?


  def render("scripts.html", _assigns) do
    ~s{<script defer src="https://www.google.com/recaptcha/api.js" async defer></script>}
    |> raw
  def render("scripts.html", assigns) do
      <script type="text/javascript" src=#{
      Routes.static_path(assigns.conn, "/js/select_all.js")
    |> raw

In assets/webpack.config.js you will find an entry section with something like this in it:

'app': glob.sync('./vendor/**/*.js').concat(['./js/app.js']),

You may add other entries in there such as:

'api': './js/api.js',

and webpack will build take the file at assets/js/api.js, build it into a bundle (e.g. resolving any imports, etc.) and place it in the publicly accessable /js dir.