In my Rails (Rails 7) app, I have some small assets (a logo and a favicon), which I want to render in production as well as in development.
I put the assets in /app/assets/images.
Since setting # config.assets.compile = true
is not recommended, i run RAILS_ENV=production bundle exec rake assets:precompile
. It then builds a whole lot of files (it runs esbuild app/javascript/application.tsx
since I have a typescript react app running in this rails app.) and puts them in /public/assets/
. But this folder is .gitignore
d by default. Since the folder is approx 5.5 Mb I can see why. Now, heroku docs tell me to add /public/assets/
to git and then my assets should show, but why then is this directory gitignored by default?
Am I missing something? Should I just remove the dir from my .gitignore file?
Or could I just put the assets in the public
folder directly? If so, how do I add an image referencing the public folder in an erb file?