2020-08-13 React项目构建:

项目构建

一,创建项目

npx create-react-app my-app
npm init react-app my-app
yarn create react-app my-app

二,项目运行

npm start 或 yarn start
npm test 或 yarn test
npm run build 或 yarn build

三,安装依赖

1.Sass:

安装:npm install node-sass --save或者yarn add node-sass
引入:@import 'styles/_colors.scss'

2.react-router-dom

安装:npm install --save react-router-dom或者yarn add react-router-dom

3.TypeScript

安装:npm install --save typescript @types/node @types/react @types/react-dom @types/jest
...........或者yarn add typescript @types/node @types/react @types/react-dom @types/jest
启动:$ npx create-react-app my-app --typescript或者yarn create react-app my-app --typescript

4.Relay(宏任务)

安装:npm install --save babel-plugin-relay@dev或者yarn upgrade babel-plugin-relay@dev
导入使用:

import graphql from 'babel-plugin-relay/macro';
// instead of:
//   import { graphql } from "babel-plugin-relay"

graphql`
  query UserQuery {
    viewer {
      id
    }
  }
`;

你可能感兴趣的:(2020-08-13 React项目构建:)