Static Assets export / import / require

Just trying to follow the example here:

I get this error:

Cannot find module 'assets/static/js/app' from '/'.

This is Chrome complaining about this script in app.html.eex

<script>require("assets/static/js/app").App.run()</script>

The tutorial states that:
Take notice of “assets/js/app”. This is not really a file name, this is the name of a module into which Brunch wrapped the code in “assets/js/app.js”

I’ve changed the script to “assets/js/app.js” instead, but no difference. My last thought is that the tutorial isn’t for 1.3(?)
This page is unavailable in Hex https://hexdocs.pm/phoenix/static_assets.html

I’d like to split my js into separate files, but I’d like to get the very simplest of examples working first! Any other tutorials covering this from first base?

Just as I post the request for help I find the answer
The script is
<script>require('js/app').App.run()</script>

That isn’t that much a tutorial, thats a blog post introducing a new feature… Somewhere in the near to 1.0 area…

I’m not sure though how you can translate it to 1.3 though… At least I can tell for sure that it seems to be the old folder layout.

1 Like