基于 Vite2、React17、React Router V6、Typescript、Eslint、Prettier 等库,是一个开箱即用得 react 项目脚手架,助您快速开发 react 项目
- axios 请求封装
- eslint+prettier 代码检查
- husky+lint-staged+cz...提交代码检查
- stylelint css 样式风格检查
- react-router v6 react 路由 v6 版本
- less
- lodash
- antd
- zustand
- router封装
1.安装依赖
pnpm install
2.本地开发
pnpm dev
3.打包上线
pnpm build
静态图片:
// 不生效
<img src="../assets/images/test.png" />
// 生效
import testPng from '../assets/images/test.png'
;<img src={testPng} />
动态图片:
import { getImageUrl } from '@/utils'
;<img src={getImageUrl('product/move.svg')} />
根目录下得 mock 文件夹下添加需要模拟数据的 ts 文件,参考mock/test.ts
即可
修改.env.production
中的VITE_ROUTER_BASE
# 路由子目录,根据部署得目录添加
VITE_ROUTER_BASE=/test/
# nginx
location /test {
try_files $uri $uri /test/index.html;
}
// 普通修改
git add .
yarn cz
git push
// 版本迭代
npm run release
git push origin --tags
- feat: 新功能(feature)
- fix: 修补 bug
- docs: 文档(documentation)
- style: 格式(不影响代码运行的变动)
- refactor: 重构(即不是新增功能,也不是修改 bug 的代码变动)
- perf: 性能优化
- test: 增加测试
- build: 编译相关的修改(例如 webpack, npm, gulp 等)
- ci: CI 相关的修改(例如 Travis, Circle 等)
- chore: 构建过程或辅助工具的变动
- revert: 回滚上一次 commit
commit 示例:
feat: 新增后台管理页面
开发者如果对以上规范不熟悉,可以使用辅助工具代替 git commit 进行提交。 有以下两种方式:
直接运行 npm run commit
代替 git commit
全局安装 cz
后运行 git cz
代替 git commit
yarn add global commitizen
yarn add global cz-conventional-changelog
参考链接: Commit message 和 Change log 编写指南 Commit types
vite:
react-router v6:
https://reactrouter.com/docs/en/v6
https://juejin.cn/post/7025418839454122015
https://juejin.cn/post/6844904096059621389
Following the Ant Design specification, we developed a React UI library antd that contains a set of high quality components and demos for building rich, interactive user interfaces.
- 🌈 Enterprise-class UI designed for web applications.
- 📦 A set of high-quality React components out of the box.
- 🛡 Written in TypeScript with predictable static types.
- ⚙️ Whole package of design resources and development tools.
- 🌍 Internationalization support for dozens of languages.
- 🎨 Powerful theme customization in every detail.
Dropped support of IE8 after [email protected]. Dropped support of React 15 and IE9/10 after [email protected]. Dropped support of IE after [email protected].
Stable: npm package You can subscribe to this feed for new version notifications: https://github.com/ant-design/ant-design/releases.atom
tea-component: