项目创建

一 .使用vite 创建项目

# 
npm create vite@latest my-app -- --template react-ts
// 不需要ts
# npm 6.x
npm init @vitejs/app my-react-app --template react
# npm 7+, 需要额外的双横线: 
npm init @vitejs/app my-reactapp -- --template react
# yarn 
yarn create @vitejs/app my-react-app --template react

二.安装react项目需要的依赖

npm i react-router-dom // 路由
npm install react-redux  // store仓库
npm install antd // antdesign下载仓库
npm install axios //  网络请求
npm i less less-loader // css 预处理器

三.使用eslint 规范代码风格

参考:AlloyTeam ESLint 规则

一.根据AlloyTeam ESLint 规则 生成 .prettierrc.js 文件,
二.配置.editorconfig
// .editorconfig
# 告诉 EditorConfig 插件,这是根文件,不用继续往上查找
root = true

# 匹配全部文件
[*]

# 设置字符集
charset = utf-8

# 缩进风格,可选 space、tab
indent_style = tab

# 缩进的空格数,当 indent_style = tab 将使用 tab_width
# 否则使用 indent_size
indent_size = 2
tab_width = 2

# 结尾换行符,可选 lf、cr、crlf
end_of_line = lf

# 在文件结尾插入新行
insert_final_newline = true

# 删除一行中的前后空格
trim_trailing_whitespace = true

# 匹配md结尾的文件
[*.md]
insert_final_newline = false
trim_trailing_whitespace = false


更多推荐