Taking a look at what ESBuild would look like in a Phoenix app

One thing I don’t understand in this thread is why go with cpx / cp -r / … and not simply have the assets live in /priv/static directly (e.g. /priv/static/images/logo.jpg)? I thought that this was the idea behind the change of .gitignore only /priv/static/assets.

that was because this post was created before 1.6 moving of the assets folder.

1 Like

This setup very nearly works for my migration, but I’m getting an error from the import "./vendor.js"; at line one of the generated app.js file:

Uncaught SyntaxError: import declarations may only appear at top level of a module

I’m not entirely sure what’s causing the issue since the root.html.heex is including the script as a module:

<script defer phx-track-static type="module" src={Routes.static_path(@conn, "/assets/app.js")}></script>

Anybody else stumble on this?