Passa al contenuto principale
Versione: Prossimo

pnpm deploy

Deploy a package from a workspace. During deployment, the files of the deployed package are copied to the target directory. All dependencies of the deployed package, including dependencies from the workspace, are installed inside an isolated node_modules directory at the target directory. The target directory will contain a portable package that can be copied to a server and executed without additional steps.

Utilizzo:

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

Nel caso in cui compili il progetto prima della distribuzione, usa anche l'opzione --prod per ignorare l'installazione delle devDependencies.

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

Utilizzo in un'immagine Docker. Dopo aver creato tutto nel tuo monorepo, fallo in una seconda immagine che usa l'immagine di base del tuo monorepo come contesto di compilazione o in una fase di compilazione aggiuntiva:

# 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"]

Opzioni

--dev, -D

Only devDependencies are installed.

--no-optional

Le dipendenze opzionali (optionalDependencies) non vengono installate.

--prod, -P

I pacchetti in devDependencies non vengono installati.

--filter <selettore_pacchetto>

Ulteriori informazioni sui filtri.

File inclusi nel progetto distribuito

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.