Symfony tried to do this, and their experience forced them to reverse this decision . The composer had information about using .gitattributes in the documentation, but deleted it .
In fact, removing some part of the package from a separate distribution path can cause more problems than it solves. From my point of view, the CLI switch --prefer-dist and --prefer-source is either a clone selector for a huge repository that takes a lot of time, or it loads a ZIP with such an exact version, but the results should be equal, that is, I should not be forced to --prefer-source for ALL of my dependencies just because one package that decided to "optimize for deployment" decided to remove the documentation and tests from their ZIP.
Yes, during development, I usually look at their code and tests to help me understand what is going on - or what SHOULD continue, and no.
Conclusion: Composer is not a deployment tool. If you care about the size of your application, your task is to remove everything that you donβt need or want, and possibly optimize other things (minimize JS and CSS, optimize images, etc.). This should not be the task of Composers or any accompanying package for this optimization for you.
source share