Skip to content

Commit

Permalink
docs include profiler (#1060)
Browse files Browse the repository at this point in the history
* docs(cli): include --profile option

* docs: fix typo in cli.md
  • Loading branch information
MH4GF authored Aug 21, 2023
1 parent 968f0b7 commit 3493b2a
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
4 changes: 3 additions & 1 deletion guide/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@ vite [root]
| `--force` | オプティマイザにキャッシュを無視して再バンドルさせる (`boolean`) |
| `-c, --config <file>` | 指定された設定ファイルを使用する (`string`) |
| `--base <path>` | public のベースパス(デフォルト: `/`) (`string`) |
| `-l, --logLevel <level>` | Info \| warn \| error \| silent (`string`) |
| `-l, --logLevel <level>` | info \| warn \| error \| silent (`string`) |
| `--clearScreen` | ログを表示する際に画面をクリアするかどうか (`boolean`) |
| `--profile` | 組み込みの Node.js インスペクタを起動する ([パフォーマンスのボトルネック](/guide/troubleshooting#パフォーマンスのボトルネック)を確認してください) |
| `-d, --debug [feat]` | デバッグログを表示する (`string \| boolean`) |
| `-f, --filter <filter>` | デバッグログをフィルタリングする (`string`) |
| `-m, --mode <mode>` | env モードを設定する (`string`) |
Expand Down Expand Up @@ -65,6 +66,7 @@ vite build [root]
| `--base <path>` | public のベースパス(デフォルト: `/`) (`string`) |
| `-l, --logLevel <level>` | Info \| warn \| error \| silent (`string`) |
| `--clearScreen` | ログを表示する際に画面をクリアするかどうか (`boolean`) |
| `--profile` | 組み込みの Node.js インスペクタを起動する ([パフォーマンスのボトルネック](/guide/troubleshooting#パフォーマンスのボトルネック)を確認してください) |
| `-d, --debug [feat]` | デバッグログを表示する (`string \| boolean`) |
| `-f, --filter <filter>` | デバッグログをフィルタリングする (`string`) |
| `-m, --mode <mode>` | env モードを設定する (`string`) |
Expand Down
22 changes: 22 additions & 0 deletions guide/troubleshooting.md
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,28 @@ Vite もしくはプラグインによって HMR が処理されていない場

最適化された依存関係を無効にするために使用されるハッシュキーは、パッケージロックの内容、依存関係に適用されるパッチ、およびノードモジュールのバンドルに影響を与える Vite 設定ファイルのオプションに依存します。つまり、Vite は [npm overrides](https://docs.npmjs.com/cli/v9/configuring-npm/package-json#overrides) のような機能を使って依存関係が上書きされたことを検出し、次のサーバー起動時に依存関係を再バンドルします。[npm link](https://docs.npmjs.com/cli/v9/commands/npm-link) のような機能を使っても、Vite は依存関係を無効化することはありません。依存関係をリンクまたはリンク解除した場合、次のサーバー起動時に `vite --force` を使って強制的に再最適化する必要があります。代わりにオーバーライドを使うことをお勧めします。オーバーライドは現在すべてのパッケージマネージャでサポートされています([pnpm overrides](https://pnpm.io/package_json#pnpmoverrides) および [yarn resolutions](https://yarnpkg.com/configuration/manifest/#resolutions) も参照してください)。

## パフォーマンスのボトルネック

アプリケーションのパフォーマンスがボトルネックとなり読み込みに時間がかかる場合、Vite 開発サーバーまたはアプリケーションをビルドするときに組み込みの Node.js インスペクタを起動して CPU プロファイルを作成することができます:

::: code-group

```bash [dev server]
vite --profile --open
```

```bash [build]
vite build --profile
```

:::

::: tip Vite 開発サーバー
アプリケーションをブラウザで開いたら、読み込みが終わるのを待ち、ターミナルに戻って `p` キーを押し(Node.js インスペクターを停止します)、次に `q` キーを押して開発サーバーを停止します。
:::

Node.js インスペクターはルートフォルダに `vite-profile-0.cpuprofile` を生成し、https://www.speedscope.app/ に遷移、`BROWSE` ボタンを使って CPU プロファイルをアップロードし、結果を検証します。

## その他

### ブラウザ互換性のためにモジュールを外部化
Expand Down

0 comments on commit 3493b2a

Please sign in to comment.