跳到主内容
版本:9.x

pnpm deploy

从 workspace 部署包。 在部署期间,已部署软件包的文件将复制到目标目录。 All dependencies of the deployed package, including dependencies from the workspace, are installed inside an isolated node_modules directory at the target directory. 目标目录将包含一个可移植包,可以将其复制到服务器并执行,无需其他步骤。

使用方法:

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>

在 docker 映像中的用法。 在你的 monorepo 中构建完所有内容后,在第二个镜像中执行此操作,该镜像使用你的 monorepo 基础镜像作为构建上下文或在额外的构建阶段:

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

配置项

--dev, -D

Only devDependencies are installed regardless of the NODE_ENV.

--no-optional

optionalDependencies are not installed.

--prod, -P

Packages in devDependencies won't be installed.

--filter &lt;package_selector>

Read more about filtering.

已部署项目中包含的文件

默认情况下,部署期间会复制项目的所有文件。 The project's package.json may contain a "files" field to list the files and directories that should be copied.