Saltar al contenido principal
Version: 10.x

pnpm deploy

Desplega un paquete desde un workspace. Durante el despliegue, los archivos del paquete desplegado se copian al directorio de destino. All dependencies of the deployed package, including dependencies from the workspace, are installed inside an isolated node_modules directory at the target directory. El directorio de destino contendrá un paquete portátil que puede ser copiado a un servidor y ejecutado sin pasos adicionales.

nota

By default, the deploy command only works with workspaces that have the inject-workspace-packages setting set to true. If you want to use deploy without "injected dependencies", use the --legacy flag or set force-legacy-deploy to true.

Uso:

pnpm --filter=<deployed project name> deploy <target directory>

In case you build your project before deployment, also use the --prod option to skip devDependencies installation.

pnpm --filter=<deployed project name> --prod deploy <target directory>

Uso en una imagen docker. Después de generar todo en su monorepo, haga esto en una segunda imagen que use su imagen base monorepo como contexto de construcción o en una etapa de generación adicional:

# syntax=docker/dockerfile:1.4

FROM workspace as pruned
RUN pnpm --filter <your package name> --prod deploy pruned

FROM node:18-alpine
WORKDIR /app

ENV NODE_ENV=production

COPY --from=pruned /app/pruned .

ENTRYPOINT ["node", "index.js"]

Opciones

--dev, -D

Only devDependencies are installed.

--no-optional

optionalDependencies are not installed.

--prod, -P

Packages in devDependencies won't be installed.

--filter <package_selector>

Read more about filtering.

--legacy

Force legacy deploy implementation.

By default, pnpm deploy will try creating a dedicated lockfile from a shared lockfile for deployment. The --legacy flag disables this behavior and also allows using the deploy command without the inject-workspace-packages=true setting.

Archivos incluidos en el proyecto desplegado

By default, all the files of the project are copied during deployment but this can be modified in one of the following ways which are resolved in order:

  1. The project's package.json may contain a "files" field to list the files and directories that should be copied.
  2. If there is an .npmignore file in the application directory then any files listed here are ignored.
  3. If there is a .gitignore file in the application directory then any files listed here are ignored.