I recently added an extra file that I want hidden (hushed.js
). I created a .gitignore
file and added hushed.js
to it. I tested it out locally, and it works perfectly. Pushed everything up, and now it breaks in Heroku. In the logs, Heroku says it cannot find that file (Error: Cannot find module '../hushed.js'
).
My Github and Heroku accounts are connected, so I just push to Github, and it automatically gets deployed in Heroku.
I deleted the .gitignore
file, and pushed it up. The Heorku app works perfect now, but alas, the hushed.js
is visible in Github.
How can I keep that file "hidden" on Github, but still used by Heroku?
You cannot. If the file is not in GitHub, Heroku will not be able to fetch it, as it retrieves the files directly from GitHub.
If this file contains sensitive data that you don't want to see in GitHub, you can use config variables.
You could also auto-generate that file at deploy time by running the generation code on postinstall.