0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

【Vercel】既存リポジトリのデプロイ方法について🛰️

0
Posted at

はじめに

Githubにある既存リポジトリをVercelへデプロイする方法、その際の注意事項について記載します。

目次

  1. 既存リポジトリのデプロイ手順
  2. デプロイ後の挙動

🧷 既存リポジトリのデプロイ手順

1. Vercel と GitHubの連携

まず、Vercel のダッシュボードにアクセスし、GitHub でログインします。

2. プロジェクトのインポート

  • ダッシュボードの 「Add New...」 ボタンをクリックし、「Project」 を選択
  • 「Import Git Repository」 というセクションが表示されるので、デプロイしたいリポジトリを選択して 「Import」 をクリック
  • 目的のリポジトリが見当たらない場合は、「Configure GitHub App」 などのリンクから、Vercel がアクセスできるリポジトリの権限を調整ください。

💡 上記Import Git Repositoryセクションで対象リポジトリが見当たらない場合は一度、GitHub の Settings > Applications > Vercel の Configure > Repository access の設定をご確認ください。
Only select repositoriesの設定になっている場合は、All repositories へ変更し再度、Vercel側のImport Git Repositoryセクションでリポジトリ検索してみてください。
スクリーンショット 2026-01-06 11.06.21.png
スクリーンショット 2026-01-06 11.06.54.png

3. プロジェクトの設定(Build & Deployment)

インポート画面に進むと、以下の設定項目が表示されます。

  • Root Directorypackage.json がリポジトリのルートにある場合は変更不要
  • Build and Output Settings:通常は自動設定のままで動作する。
  • Environment Variables.env ファイルに記述しているような環境変数(APIキーなど)がある場合は、ここで入力
  • Framework PresetNext.js, Nuxt, Vite, Create React App など、Vercel がプロジェクトの構成ファイルを読み取って自動判別してくれます。
    基本はそのままで OK

4. デプロイの実行

設定が完了したら 「Deploy」 ボタンを押します。数分でビルドが完了し、公開用の URL が発行されます。
スクリーンショット 2026-01-06 11.21.25.png

💡 デプロイは成功するがNOT FOUNRとなる場合
スクリーンショット 2026-01-06 11.22.37.png

対象のVercelプロジェクト > Deployments > DeploymentsIDクリック > Source > Output をご確認ください。
スクリーンショット 2026-01-06 11.28.38.png

Outputでは、アプリケーションのルートファイル(初めに読み込まれるファイル)が示されている必要があります。
スクリーンショット 2026-01-06 11.26.20.png
スクリーンショット 2026-01-06 11.27.27.png

なので、もしここにindex.jsindex.htmlがなければ一度、Project Settings > Build and Deployment > Framework Settings > Output Directory が正しいか確認してみてください。
srcやpublicフォルダにルートファイルがある場合は、添付の.だとNOT FOUNRになる可能性があります。
スクリーンショット 2026-01-06 11.35.09.png

上記Project Settingsで誤りがある場合は修正後、CurrentコミットをRedeployして、変更分を反映させてください。
スクリーンショット 2026-01-08 16.52.10.png

🧷 デプロイ後の挙動

Vercel の大きな特徴は、Git との自動同期です。

  • Main ブランチへの Push:今後、ローカルで作業して git push するたびに、Vercel が自動的に新しいコミットを検知して再デプロイ(Production Deployment)を行います。
  • プルリクエスト:他のブランチから PR を作成すると、そのブランチ専用のプレビュー環境(Preview Deployment) が自動生成されます。

💡 もし CLI で行いたい場合、ブラウザを使わずターミナルからコマンド一発でデプロイすることも可能

  • npm i -g vercel で CLI をインストール
  • プロジェクトのルートディレクトリで vercel コマンドを実行
  • 対話形式の質問に答えるだけでデプロイが完了
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?