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.
From pnpm v10.0.0 to v10.2.1, deploy
requires the injected-workspace-dependencies
setting to be set to true
. From pnpm v10.2.1 onward, injected-workspace-dependencies=true
is only required for lockfile deploy.
使い方
pnpm --filter=<デプロイ先のプロジェクト名> deploy <対象ディレクトリ>
デプロイ前にプロジェクトをビルドする場合は、 --prod
オプションを使用して devDependencies
のインストールをスキップします。
pnpm --filter=<デプロイ先のプロジェクト名> --prod deploy <対象ディレクトリ>
Docker イメージでの使用方法。 モノレポですべてをビルドしたら、モノレポベースイメージをビルドコンテキストとして使用する 2 番目のイメージで、または追加のビルド ステージで、これを行います。
# 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"]
Options
--dev, -D
Only devDependencies
are installed.
--no-optional
optionalDependencies
をインストールしません。
--prod, -P
devDependencies
のパッケージはインストールされません。
--filter <package_selector>
詳細についてはフィルタリングに関するドキュメントを参照してください。
--legacy
Force legacy deploy implementation.
Since pnpm v10, by default, pnpm deploy
will try creating a dedicated lockfile from a shared lockfile for deployment. The --legacy
flag disables this behavior.
デプロイされたプロジェクトに含まれるファイル
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:
- The project's
package.json
may contain a "files" field to list the files and directories that should be copied. - If there is an
.npmignore
file in the application directory then any files listed here are ignored. - If there is a
.gitignore
file in the application directory then any files listed here are ignored.