メインコンテンツへスキップ
非公式ベータ版翻訳

このページは PageTurner AI で翻訳されました(ベータ版)。プロジェクト公式の承認はありません。 エラーを見つけましたか? 問題を報告 →

キャッシュの共有

Lernaが提供する計算キャッシュは複数のマシン間で分散可能です。キャッシュの実装を独自に構築するか、Nx Cloudを利用する選択肢があります。Nx Cloudは分散キャッシュを高速かつ設定不要で実現するアプリケーションで、OSSプロジェクトとほとんどのクローズドソースプロジェクトで完全無料で利用できます(詳細はこちら)。

インタラクティブなブラウザベースのワークフローで、ワークスペースをNx Cloudに簡単に接続できます。 以下のコマンドをlernaワークスペースのルートで実行すると、プロセスが開始され、自動的にブラウザウィンドウが開いて専用の接続URLが表示されます:

Terminal Output
npx nx connect-to-nx-cloud

✔ Opening Nx Cloud https://cloud.nx.app/connect/abc123456 in your browser to connect your workspace.

リモートキャッシュの動作を確認するには、以下を実行してください:

lerna run build --scope=header && nx reset && lerna run build --scope=header
Terminal Output
> lerna run build --scope=header

> header@0.0.0 build
> rimraf dist && rollup --config

src/index.tsx → dist...
created dist in 786ms

—————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————

Lerna (powered by Nx) Successfully ran target build for project header (2s)

See logs and investigate cache misses at https://cloud.nx.app/runs/k0HDHACpL8


> NX Resetting the Nx workspace cache and stopping the Nx Daemon.

This might take a few minutes.


> NX Daemon Server - Stopped


> NX Successfully reset the Nx workspace.


> lerna run build --scope=header [remote cache]


> header@0.0.0 build
> rimraf dist && rollup --config


src/index.tsx → dist...
created dist in 786ms

—————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————

Lerna (powered by Nx) Successfully ran target build for project header (664ms)

Nx read the output from the cache instead of running the command for 1 out of 1 tasks.

Nx Cloud made it possible to reuse header: https://nx.app/runs/P0X6ZGTkqZ

クラウド利用のスキップ

--skip-nx-cache がキャッシュ使用をスキップするのと同様に、--no-cloud を渡すとNx Cloudの利用をスキップします。環境変数 NX_NO_CLOUDtrue を設定することも可能です。