How to tell composer to set minimal files

I have composer.json for a twig request:

 "require": { "twig/twig": "~1.0", ... } 

This twig package installs a folder called doc .

Basically, my vendor folder is getting too big, especially since I am distributing my project with it (this is a WordPress plugin).

Is there a way to tell the composer to include only “miniature” or at least the smallest number of files, and not such things as documentation, tests, etc.?

+5
source share
3 answers

You cannot, because you (as a client-dependent) do not have the right to decide how your addiction should act. Its up to him! Just deliver your projects without dependency files, turn on composer.json instead.

This question has been asked before, each time with a No or sth answer similar to it.
Here are some examples:
How to install specific files from a package using composer.json
How to configure composer.json to download specified files only?


UPDATE ## [important!]

There seems to be only one way similar to what you need.

There is an option that developers may or may not use, and its complex game with --prefer-dist and .gitattributes .
The developer could use the .gitattributes file to ignore some files and folders during packaging for -prefer-dist mode. sth like this:

 /docs export-ignore /tests export-ignore /.gitattributes export-ignore /.gitignore export-ignore /phpunit.xml export-ignore 

Then when providing dependencies, Packagist uses this .zip file made in github to drag out the -prefer-dist dependencies and then unzip them after loading (much faster than cloning). Thus, if a developer ignores tests, documents, and other logically inappropriate files by listing them in .gitattributes, the archives do not contain them, becoming much easier.

This seems to be the only way that, again, is not based on a client-code solution and, obviously, is a manufacturer-oriented tool.

But you can check -prefer-dist when installing the necessary dependency, maybe they made this option available, and you can get a much lighter version.

+4
source

I do not know if I understood your question correctly. But if you create a plugin, you do not provide the supplier folder, instead you write the dependencies in your composer.json file, and the user who wants to use your plugin loads the sources in his supplier folder as the dependency that is necessary for your plugin.

I don’t think you can “minimize” your dependencies.

0
source

Simple anwser you cannot.

Install the Composer package in the way that is defined in composer.json in the package repository. And (package) the author decides what should be in it. This is the idea here.

The idea of ​​the composer is that you distribute your code without the supplier’s catalog, and the “client” should start installing the composer on its side.

And it's normal that the dir provider takes up a lot of space: /

0
source

Source: https://habr.com/ru/post/1264393/


All Articles