Skip to content

Conversation

@crbelaus
Copy link
Contributor

@crbelaus crbelaus commented Aug 5, 2024

We are getting reports that when a mix release is deployed to production the dashboard breaks because it can't find the CSS and JS files.

I've built a mix release locally and it works well. It only fails when deployed (for example to fly.io). This has been confirmed in the error report.

Interestingly enough, when I deployed the release to fly.io I saw that the priv/ folder is not present. I am extremely confused as of why this happens as I see that other dependencies such as phoenix do include that folder. I reviewed the mix.exs from both projects and I couldn't find what would cause this difference.

Anyway, I was able to fix this problem by reading the CSS and JS files on compilation. Since those files are included in the package, we can be confident that they exist at that point.

Since the static files were present in .gitignore I was having trouble when doing tests as I was pointing directly to the GitHub repository. Since Mix supports getting dependencies from GitHub directly I had to include those files in the repository. Otherwise people won't be able to run the error tracker pointing to a particular branch or commit.

It may be a good idea to set a pre-commit hook to ensure that they are always up to date.

Fixes #30

@crbelaus crbelaus requested a review from odarriba August 5, 2024 16:04
@crbelaus crbelaus self-assigned this Aug 5, 2024
@crbelaus crbelaus added the bug Something isn't working label Aug 5, 2024
Copy link
Contributor

@odarriba odarriba left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved! I have also added a fix of a typo in the layout file.

I think we can force Mix to include priv dir in releases with the build_embedded option, but it looks like it's easier to just include it in compile time and that's all. Less I/O and more efficiency.

@crbelaus crbelaus changed the title Read assets on compilation Read assets during compilation Aug 6, 2024
@crbelaus crbelaus merged commit 11dde5e into main Aug 6, 2024
@crbelaus crbelaus deleted the runtime-asset-paths branch August 6, 2024 13:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Error loading assets on a mix release

3 participants