はじめに
nodeのバージョン管理のために、微妙に開発環境はdockerにしてみる...(必要は無いかw
docker-compose.yml
version: "3"
services:
react:
container_name: react
image: node:8.13-alpine
working_dir: /src
volumes:
- ./src:/src
ports:
- 3000:3000
create-react-appで雛形の作成
開発環境のrootとなるディレクトリを作成し、create-react-appをローカルにインストールする
$ mkdir src
$ docker-compose run --rm react yarn add create-react-app
sampleアプリを作成してみる
$ docker-compose run --rm react npx create-react-app sample
(中略)
Success! Created sample at /src/sample
Inside that directory, you can run several commands:
yarn start
Starts the development server.
yarn build
Bundles the app into static files for production.
yarn test
Starts the test runner.
yarn eject
Removes this tool and copies build dependencies, configuration files
and scripts into the app directory. If you do this, you can’t go back!
We suggest that you begin by typing:
cd sample
yarn start
Happy hacking
デバッグ用のサーバーを起動する
$ docker-compose run --service-ports --workdir="/src/sample" --detach react yarn start