目次
- dockerまたはdocker desktopをインストール
- dockerまたはdocker desktopを起動
- リポジトリをクローン
- プロジェクトディレクトリに以下のファイルを作成
- プロジェクトディレクトリで以下のコマンドを実行
$ docker-compose build
$ docker-compose up -d
- ここまでで、フロントエンド・Storybook・バックエンド・Firebaseのそれぞれのコンテナが作成されます。
- node_modulesはホスト側に作成されないので、VSCodeのDocker拡張機能などを利用してコンテナ内で作業することをお勧めします。
- 編集内容はホスト側と同期されるので、コンテナを消してもコードの編集内容は残ります。
- パッケージを追加したい
- コンテナ内で
yarn add
をした後にdocker-compose restart
でコンテナを再起動
- コンテナ内で
- node_modulesを作り直したい
- まずはコンテナを削除
- frontend-node-modulesというDocker Volumeを削除
docker-compose up -d
を実行(環境丸ごと作り直したい場合はdocker-compose build --no-cache
)
- node_modulesがホスト側にあるとDockerが正常に動作しない可能性があります
- Volumeのnode_modulesより、ホスト側のnode_modulesが優先的に参照される場合があるみたいです。
- ライブラリインストール
yarn
- env ファイルの生成
vi .env
中身はこちらをコピー(notion リンクなので未招待の人は Teru まで)
- モックアップサーバーの起動(別のターミナル推奨)
$ cd mock_server
$ json-server -w db.json --port 3001
- 起動
yarn start
- テスト
yarn test
スナップショットテストでエラーが出たときは内容を確認し問題がなければ u を押すことでスナップショットをアップデートできる。
以上
StoryBook を利用することで UI コンポーネントを確認することができる。
以下のコマンドで起動
yarn storybook
node.js を既にインストールしている場合は一度アンインストールしてください。
https://github.com/nullivex/nodist/releasesからNodistSetup-vx.x.x.exeをダウンロード
(今回は v0.9.1 をダウンロードしました)
- Node.js のインストール
> nodist + 16.11.0
> nodist 16.11.0
- npm のバージョン合わせ
> nodist npm match
- yarn のインストール
npm install -g yarn
- git のインストール
https://git-scm.com/ここからダウンロードしてインストール
nodenv なるものをインストールするらしい。
ちげくんの ScrapBox を参考にインストールしてください。
https://scrapbox.io/chige12memo/Mac_book_%E7%92%B0%E5%A2%83%E6%A7%8B%E7%AF%89
> node -v
v16.11.0
> npm -v
8.0.0
> yarn -v
1.22.17
> git --version
git version 2.33.0.windows.2
> npx create-react-app --version
Need to install the following packages:
create-react-app
Ok to proceed? (y) y
npm WARN deprecated tar@2.2.2: This version of tar is no longer supported, and will not receive security updates. Please upgrade asap.
4.0.3
このリポジトリをクローン
git clone https://github.com/CodeParty2021/code_party_front.git
このプロジェクトをクローンした後、プロジェクトルートディレクトリで以下を実行
> yarn
> cd code_party_front
code_party_front > yarn start
http://localhost:3000にアクセスするとReactのページが表示される
> npx create-react-app code_party_front --template typescript
色々出てくる
最後にHappy hacking!が出てきたらOK
- PATH not updated, original length x > 1024 が出た時
- 環境変数に C:\Program Files (x86)\Nodist\bin を追加しましょう.
- cb.apply is not a function が出た時
- nodist npm match を実行しましょう。
- そのほか
- 頑張って調べて!
https://qiita.com/satoyan419/items/56e0b5f35912b9374305
以下、React のデフォルト README
This project was bootstrapped with Create React App.
In the project directory, you can run:
Runs the app in the development mode.
Open http://localhost:3000 to view it in the browser.
The page will reload if you make edits.
You will also see any lint errors in the console.
Launches the test runner in the interactive watch mode.
See the section about running tests for more information.
Builds the app for production to the build
folder.
It correctly bundles React in production mode and optimizes the build for the best performance.
The build is minified and the filenames include the hashes.
Your app is ready to be deployed!
See the section about deployment for more information.
Note: this is a one-way operation. Once you eject
, you can’t go back!
If you aren’t satisfied with the build tool and configuration choices, you can eject
at any time. This command will remove the single build dependency from your project.
Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except eject
will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own.
You don’t have to ever use eject
. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it.
You can learn more in the Create React App documentation.
To learn React, check out the React documentation.