prune
Generate a partial monorepo for a target package. The output will be placed into a directory named out
containing the following:
- The full source code of all internal packages needed to build the target.
- A pruned lockfile containing the subset of the original lockfile needed to build the target.
- A copy of the root
package.json
.
Example
Starting with a repository with the following structure:
Run turbo prune frontend
to generate a pruned workspace for the frontend
application in an out
directory:
Options
--docker
Defaults to false
.
Alter the output directory to make it easier to use with Docker best practices and layer caching. The directory will contain:
- A folder named
json
with the pruned workspace'spackage.json
files. - A folder named
full
with the pruned workspace's full source code for the internal packages needed to build the target. - A pruned lockfile containing the subset of the original lockfile needed to build the target.
Using the same example from above, running turbo prune frontend --docker
will generate the following:
--out-dir <path>
Defaults to ./out
.
Customize the directory the pruned output is generated in.
--use-gitignore[=<bool>]
Default: true
Respect .gitignore
file(s) when copying files to the output directory.
Comparison to pnpm deploy
While both turbo prune
and pnpm deploy
are used to isolate packages in a monorepo, they serve different purposes and produce different outputs.
Where turbo prune
generates a partial monorepo, pnpm deploy
generates a directory that only contains the contents of the target package.
The pnpm deploy
generated directory has a self-contained node_modules
with hard linked internal dependencies.
This results in a portable package that can be directly copied to a server and used without additional steps.
The repository structure is not retained, as the focus is on producing a standalone deployable package.
Was this helpful?