Giter Site home page Giter Site logo

react-cli's Introduction

react脚手架

总体架构

基于react官方脚手架,并增加自选框架(如下)。优点是增加可配置性,并且每次创建都会保持和官方最新同步。

类型 可选框架名称
语言 JavaScript / TypeScript
状态管理库 Redux / Mobx
css预处理器 SCSS / LESS / styled-components
UI组件 Antd / Ant-mobile
代码规范 Airbnb
HTTP库 Axios
路由 react-router

安装

npm i xd-react-cli -g

初始化项目

react-cli create <app-name>

用户第一次创建有两个选项

  • default (JavaScript, Redux, Antd, Less, Router, ESLint) 默认配置
  • Manually select features 选择配置

第二次创建的时候会多一个用户上次选择过的选项配置config

项目中使用

npm start

启动本地调试 启动地址和配置可以在config-overrides.js修改

npm run build

应用打包

npm run test

测试应用

npm run eject

react-scripts暴露到应用顶层,操作不可逆,弹射后不能随官方脚手架升级

目录

public

favicon.icn --项目图标

index.html --html入口

manifest.json --PWA应用配置文件

src

api  --异步请求集合

assets  --静态资源

components  --细小的组件,能复用

routes --路由集合管理

modules --各个业务模块

stores  --状态管理

style  --全局样式(页面样式写在各自页面中)

utils  --工具类文件(包括fetch等)

test --测试目录

App.js --应用入口文件

index.js --入口文件

serviceWorker.js -- PWA应用缓存离线策略,需要在index.js中开启

config-overrides.js -- 配置文件 Webpack devServer jest都在这里配置

.babelrc -- babel相关配置

关于config-overrides配置

完全不用担心无法定制的问题,用户可以在里面配置Webpack devServer jest。可以在这里添加自定义的config配置来增加修改loader, plugin, optimization进行配置。webpackMerge使用混入的方式去添加config。

代码规范

请遵守Airbnb JavaScript的代码规范:Airbnb JavaScript 代码规范中文版

未完成

  1. TypeScript相关支持,后期加上

react-cli's People

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.