Should I upload to my Git repository the static files generated by Django’s collectstatic?

Asked

Viewed 50 times

0

After generating the static files from my web app using:

python manage.py collectstatic

I am in doubt if I should send or not the content generated in the directory static/ to my repository. It’s good practice to use these files in Git?

  • 1

    Despite of that question be about Javascript, is related and can clarify you a little

  • 1

    Technically nay, since you would probably have to redo the build with each modification, most similar programs never send the Static versions, of course it will do no harm either, but send compressed/minified files with hash-based names, that there may be more than one, because usually the old ones are not removed instantly with each version, so it would only hinder the understanding of the history of what you did in your GIT stream.

  • Can you verify the answer? Don’t forget to accept it if you are satisfied with it.

1 answer

3


More important than the answer, I would say that are 2 questions that should be asked: por que? and para que? you would do that.

  • Static content is not versioned code, it is generated code.
  • It would require a manual process in all commits to update the generated code (it could be automated, but it’s not trivial under these conditions).
  • On many occasions new files with completely different names are generated, which would cause your repository to increase in size dramatically.

If you want to "save" the generated static code, create a CI/CD process to create versions alongside your commits/releases and publish somewhere else "separate" from your repository. And put separate with quotes because it is possible to organize it next to your repository on github, gitlab and the like. This way you can separate what is code in your GIT repository from what is generated, to be used later, and still have a link and trace between both.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.