1
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?

AmplifyでReact+Viteアプリをデプロイする

1
Posted at

こんにちは。
株式会社クラスアクト インフラストラクチャ事業部の大塚です。

今回はAmplifyを使ってReact(Vite)のアプリをデプロイしてきたいと思います。
※当方インフラのエンジニアなので、フロント系の話は勉強中です。その認識で閲覧頂ければと思います。

環境イメージ

growi-ページ15.drawio.png

手順

github

githubにamplifyというリポジトリを作成しておきます
名前は任意のもので大丈夫です
image (15).png
併せてローカルのPCにC:\Users\ohtsu\Documents\AWSを用意します
image (16).png

VSCodeで上記フォルダを開きます
次にVSCodeで以下を実行し、リポジトリをクローンします。

C:\Users\ohtsu\Documents\AWS>git config --global user.email "メールアドレス"
C:\Users\ohtsu\Documents\AWS>git config --global user.name "名前"
C:\Users\ohtsu\Documents\AWS>git clone https://github.com/ohtsuka-shota/amplify
Cloning into 'amplify'...
remote: Enumerating objects: 3, done.
remote: Counting objects: 100% (3/3), done.
remote: Total 3 (delta 0), reused 0 (delta 0), pack-reused 0 (from 0)
Receiving objects: 100% (3/3), done.

image (17).png
image (18).png

GitHubからクローンしたフォルダ(C:\Users\ohtsu\Documents\AWS\amplify)で以下を実行
(ローカルでnode.jsとかをインストールしてREACTが実行できる必要があります。)
vite@latestで実行するとAmplifyでデプロイする際にバージョンエラーを吐かれるので、あえて6.0.0でやっています。

C:\Users\ohtsu\Documents\AWS>cd amplify
C:\Users\ohtsu\Documents\AWS\amplify>npm create vite@6.0.0 . -- --template react

> npx
> cva . --template react

√ Current directory is not empty. Please choose how to proceed: » Ignore files and continue

Scaffolding project in C:\Users\ohtsu\Documents\AWS\amplify...

Done. Now run:

  npm install
  npm run dev


C:\Users\ohtsu\Documents\AWS\amplify>npm install 

added 197 packages, and audited 198 packages in 8s

33 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities

npm run devを実行して、REACTのウェルカムページを表示できることを確認します。

C:\Users\ohtsu\Documents\AWS\amplify>npm run dev

> amplify@0.0.0 dev
> vite


  VITE v7.0.2  ready in 815 ms

  ➜  Local:   http://localhost:5173/
  ➜  Network: use --host to expose
  ➜  press h + enter to show help

image (19).png

githubにpushしていきます

C:\Users\ohtsu\Documents\AWS\amplify>git add .
warning: in the working copy of '.gitignore', LF will be replaced by CRLF the next time Git touches it
warning: in the working copy of 'README.md', LF will be replaced by CRLF the next time Git touches it
warning: in the working copy of 'eslint.config.js', LF will be replaced by CRLF the next time Git touches it
warning: in the working copy of 'index.html', LF will be replaced by CRLF the next time Git touches it
warning: in the working copy of 'package-lock.json', LF will be replaced by CRLF the next time Git touches it
warning: in the working copy of 'package.json', LF will be replaced by CRLF the next time Git touches it
warning: in the working copy of 'vite.config.js', LF will be replaced by CRLF the next time Git touches it
warning: in the working copy of 'src/App.css', LF will be replaced by CRLF the next time Git touches it
warning: in the working copy of 'src/App.jsx', LF will be replaced by CRLF the next time Git touches it
warning: in the working copy of 'src/index.css', LF will be replaced by CRLF the next time Git touches it
warning: in the working copy of 'src/main.jsx', LF will be replaced by CRLF the next time Git touches it

C:\Users\ohtsu\Documents\AWS\amplify>git commit -m "first-push" 
[main 42e6d5c] first-push
 10 files changed, 2166 insertions(+), 67 deletions(-)
 create mode 100644 public/vite.svg
 create mode 100644 src/App.css
 create mode 100644 src/App.jsx
 create mode 100644 src/assets/react.svg
 create mode 100644 src/index.css
 create mode 100644 src/main.jsx

C:\Users\ohtsu\Documents\AWS\amplify>git push origin main
Enumerating objects: 20, done.
Counting objects: 100% (20/20), done.
Delta compression using up to 20 threads
Compressing objects: 100% (13/13), done.
Writing objects: 100% (15/15), 20.00 KiB | 10.00 MiB/s, done.
Total 15 (delta 3), reused 7 (delta 0), pack-reused 0
remote: Resolving deltas: 100% (3/3), completed with 3 local objects.
To https://github.com/ohtsuka-shota/amplify
   e77db01..42e6d5c  main -> main

GitHubにpushできたことを確認します。
image (20).png

Amplifyでアプリのデプロイ

Amplipyの管理画面にアクセスしてアプリケーションをデプロイを押下します。
image (21).png

Githubと連携するので、それを選択して次に進みます。
image (22).png
Githubのログイン画面がポップするので自分のユーザアカウントを入力してサインインします。
image (23).png
image (24).png
image (25).png

リポジトリはamplify、branchはmain。
image (26).png
アプリの名前を任意のものにして次に進む
image (27).png

確認してデプロイしていきます。
screencapture-ap-northeast-1-console-aws-amazon-amplify-create-review-2025-07-05-23_29_29 (1).png

デプロイが進行します。
image (28).png
デプロイが完了するとデプロイ済みとなります。ドメインを押下すると、Reactの画面が出てきます。
デプロイできていますね。
image (29).png
image (30).png

リポジトリやデプロイ履歴を確認することも出来るようですね。
image (31).png

Reactアプリを更新してみる

App.jsxを更新し、それをGithub・Amplify経由でデプロイしていきます。
更新した内容は以下になります。

import { useState } from 'react'
import reactLogo from './assets/react.svg'
import viteLogo from '/vite.svg'
import './App.css'

function App() {
  const [count, setCount] = useState(0)

  return (
    <>
      <div>
        <a href="https://vite.dev" target="_blank">
          <img src={viteLogo} className="logo" alt="Vite logo" />
        </a>
        <a href="https://react.dev" target="_blank">
          <img src={reactLogo} className="logo react" alt="React logo" />
        </a>
      </div>
      <h1>Vite + React Ver 2.0</h1>
      <div className="card">
        <button onClick={() => setCount((count) => count + 1)}>
          count is {count}
        </button>
        <p>
          Edit <code>src/App.jsx</code> and save to test HMR
        </p>
      </div>
      <p className="read-the-docs">
        Click on the Vite and React logos to learn more
      </p>
    </>
  )
}

export default App

変更したら、内容を確認するためにローカルでnpm run devを実行します。
以下のように出力内容が変わっていることがわかります。
image (32).png

これをGitHubにpushします。
changes for v2というメッセージとともにpushしました。

C:\Users\ohtsu\Documents\AWS\amplify>git add .
warning: in the working copy of 'src/App.jsx', LF will be replaced by CRLF the next time Git touches it

C:\Users\ohtsu\Documents\AWS\amplify>git commit -m "changes for v2"
[main 154e8b7] changes for v2
 1 file changed, 1 insertion(+), 1 deletion(-)

C:\Users\ohtsu\Documents\AWS\amplify>git push origin main
Enumerating objects: 7, done.
Counting objects: 100% (7/7), done.
Delta compression using up to 20 threads
Compressing objects: 100% (4/4), done.
Writing objects: 100% (4/4), 367 bytes | 367.00 KiB/s, done.
Total 4 (delta 3), reused 0 (delta 0), pack-reused 0
remote: Resolving deltas: 100% (3/3), completed with 3 local objects.
To https://github.com/ohtsuka-shota/amplify
   42e6d5c..154e8b7  main -> main

AmplifyでGitHubにpushされたことを検知してデプロイが自動で走ります。
デプロイ済みになったら、ドメインを押下します。
image (33).png
image (34).png

変更が反映されてことが確認できました。
image (35).png

1
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
1
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?