masalibの日記

システム開発、運用と猫の写真ブログです

ReactとExpressとGraphQLの開発環境をつくるなら「React Starter Kit」が最強

社内の勉強会でReactを勉強しています
GraphQLの所ではまってしまい、また1から勉強することにしました

以前の記事でreactとexpressとつなぐとという事をやったのですが

masalib.hatenablog.com

超絶、無駄でした
今どきは一発でつくれるそうです
yarnが入っていない人はyarnをインストールしてください

github.com

昔からあるみたいなのですがGraphQLに対応してくれた所が素敵すぎwww

インストール

$ git clone -o react-starter-kit -b master --single-branch https://github.com/kriasoft/react-starter-kit.git MyApp
$ cd MyApp
$ yarn install
$ yarn start

f:id:masalib:20180817024614j:plain

これだけでReactとExpressとGraphQLの開発環境ができます

ディレクトリ構成

├── /build/                     # The folder for compiled output
├── /docs/                      # Documentation files for the project
├── /node_modules/              # 3rd-party libraries and utilities
├── /public/                    # Static files which are copied into the /build/public folder
├── /src/                       # The source code of the application
│   ├── /components/            # React components
│   ├── /data/                  # GraphQL server schema and data models
│   ├── /routes/                # Page/screen components along with the routing information
│   ├── /client.js              # Client-side startup script
│   ├── /config.js              # Global application settings
│   ├── /server.js              # Server-side startup script
│   └── ...                     # Other core framework modules
├── /test/                      # Unit and end-to-end tests
├── /tools/                     # Build automation scripts and utilities
│   ├── /lib/                   # Library for utility snippets
│   ├── /build.js               # Builds the project from source to output (build) folder
│   ├── /bundle.js              # Bundles the web resources into package(s) through Webpack
│   ├── /clean.js               # Cleans up the output (build) folder
│   ├── /copy.js                # Copies static files to output (build) folder
│   ├── /deploy.js              # Deploys your web application
│   ├── /postcss.config.js      # Configuration for transforming styles with PostCSS plugins
│   ├── /run.js                 # Helper function for running build automation tasks
│   ├── /runServer.js           # Launches (or restarts) Node.js server
│   ├── /start.js               # Launches the development web server with "live reload"
│   └── /webpack.config.js      # Configurations for client-side and server-side bundles
├── Dockerfile                  # Commands for building a Docker image for production
├── package.json                # The list of 3rd party libraries and utilities
└── yarn.lock                   # Fixed versions of all the dependencies

公式より引用

長所

  • 迷わずに1発で開発環境がつくれること
  • package.jsonが1ファイル
  • herokuのアップを意識したコマンドが用意されている

短所

残念なのはReduxなどのstate系のライブラリーが入っていません。
チュートリアルにも書いてあるのですがそちらは自力でインストールする必要があります。
100%使うののでこの部分も自動化してほしかった。
ブランチはあるのでそっちからインストールすればできるみたい(未確認)

今後

スターの数も1万8000あるので、今後もgitリポジトリは更新されると思うのでチェックしていきたい