Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ignore digested assets #5854

Conversation

almirsarajcic
Copy link
Contributor

Currently, some digested assets aren't ignored by either git or Docker: favicon, robots.txt file, images, fonts, etc. Basically, only digested CSS and JS are. People testing (prod) releases locally are affected by this issue.

I couldn't find a better solution than relying on the format of the digested filename (hash is 32 characters long) and the extension of the Gzip archive. I've used this for years in one of the projects I'm working on.

To reproduce, generate a new Phoenix app, then run mix assets.deploy.

Before:

➜  infra_check git:(main) mix assets.deploy

Rebuilding...

Done in 240ms.

  ../priv/static/assets/app.js  109.8kb

⚡ Done in 10ms
Check your digested files at "priv/static"
➜  infra_check git:(main) ✗ git status
On branch main
Untracked files:
  (use "git add <file>..." to include in what will be committed)
        priv/static/favicon-91f37b602a111216f1eef3aa337ad763.ico
        priv/static/images/logo-06a11be1f2cdde2c851763d00bdd2e80.svg
        priv/static/images/logo-06a11be1f2cdde2c851763d00bdd2e80.svg.gz
        priv/static/images/logo.svg.gz
        priv/static/robots-9e2c81b0855bbff2baa8371bc4a78186.txt
        priv/static/robots-9e2c81b0855bbff2baa8371bc4a78186.txt.gz
        priv/static/robots.txt.gz

nothing added to commit but untracked files present (use "git add" to track)

After:

➜  infra_check git:(ignore-digested-assets) mix assets.deploy

Rebuilding...

Done in 234ms.

  ../priv/static/assets/app.js  109.8kb

⚡ Done in 9ms
Check your digested files at "priv/static"
➜  infra_check git:(ignore-digested-assets) git status
On branch ignore-digested-assets
nothing to commit, working tree clean

@josevalim
Copy link
Member

Thanks for the PR. However I am worried about false positives here, especially if someone adds an external .gz extension. Given digest usually happens inside a Dockerfile or in a build server, I'd prefer to not add this change to avoid other surprises.

@almirsarajcic
Copy link
Contributor Author

Makes sense. I'll just continue using this in my project templates.

@almirsarajcic almirsarajcic deleted the ignore-digested-assets branch July 10, 2024 06:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants