clemensm
How do you prevent phx.digest files from being commited with Phoenix 1.6?
Hi everyone
I was just wondering what ways you’ve come up with to prevent files created with mix phx.digest from being commited with the new default layout of Phoenix 1.6.
I.e. in Phoenix 1.6 static files like images etc go directly into the /priv/static folder by default, and only the generated css and js files in priv/static/assets are ignored in the .gitignore file. So if someone runs mix phx.digest in his development environment and then accidentially just runs git add .; git commit, all those digested files will be commited as well, something I personally find rather annoying.
My solution for now is that I’ve moved the static asset files to assets/static, and am then using watchexec to rsync all changes during development into priv/static. I’ve made a more detailed post about it if someone is interested.
However I’m not entirely happy with this approach, because I actually like the idea of simple layouts, i.e. files are in the same place in development like in production. So my open question is basically: Has anyone of you come up with an alternative to this? I’ve thought about using a git pre-commit hook as well, however that did not work as ex
pcected. Or maybe an entirely different idea?
Edit: Changed Topic/Category
Most Liked
ruslandoga
I’ve added
/priv/static/**/*.gz
/priv/static/**/*-????????????????????????????????.*
/priv/static/cache_manifest.json
to my .gitignore. It’s error-prone but seems to work for now.
kuroda
According to the discussion on the issue #4505 referred by wanton7, we should run mix phx.digest.clean --all before running git add .; git commit.
If you run mix phx.digest in order to create a release, you can automate this process by a shell script like this:
mix phx.digest
mix release
mix phx.digest.clean --all
thiagomajesk
You could try configuring the pipeline to output in the same folders it used to be?
I honestly don’t know why this was changed tbh. I guess it has something to do with avoiding copying assets over to the priv folder. I also don’t recall reading about the process of changing it when Phoenix 1.6 came out, so as of right now I’ve been using Vite to replace Webpack because I found the transition easier than having almost no frontend pipeline out of the box.
Popular in Questions
Other popular topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #advent-of-code
- #elixirconf-us
- #distillery
- #processes
- #forms
- #api
- #metaprogramming
- #security
- #performance









