fenglonghui / jira

react hook应用,优化代码,提升性能,自定义loader、plugin,开发库组件,利用webpack打包进行优化,微前端的应用

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Getting Started with Create React App

This project was bootstrapped with Create React App.

一. 项目创建初始化、配置代码格式化、提交前检查、并自动格式化代码

1. create-react-app simple

npx create-react-app jira --template typescript

2. 设置 baseUrl,

在 tsconfig.json 文件中,设置统一的绝对路径,所有引入的也页面都是从 src 文件下来查找的

3. 安装统一的格式化工具 prettier

yarn add --dev --exact prettier

4. 创建配置文件.prettierrc.json、.prettierignore

5. 实现提交之前自动格式化文件内容,需安装工具

npx mrm lint-staged

6. 配置 lint-staged

"*.{js,css,md,ts,tsx}": "prettier --write"

7. prettier 和 eslint 一起工作会有冲突,需要安装工具解决冲突 eslint-config-prettier

yarn add eslint-config-prettier -D

8. 提交代码之前检检测代码是否符合规范,安装工具 commitlint 来检查

yarn add @commitlint/config-conventional @commitlint/cli -D

9. 运行终端命令,创建 commitlint.config.js 配置文件

echo "module.exports = {extends: ['@commitlint/config-conventional']}" > commitlint.config.js

10. 运行命令, 生成 commit-msg 文件

npx husky add .husky/commit-msg "yarn commitlint --edit $1"

Available Scripts

In the project directory, you can run:

npm start

Runs the app in the development mode.
Open http://localhost:3000 to view it in the browser.

The page will reload if you make edits.
You will also see any lint errors in the console.

npm test

Launches the test runner in the interactive watch mode.
See the section about running tests for more information.

npm run build

Builds the app for production to the build folder.
It correctly bundles React in production mode and optimizes the build for the best performance.

The build is minified and the filenames include the hashes.
Your app is ready to be deployed!

See the section about deployment for more information.

npm run eject

Note: this is a one-way operation. Once you eject, you can’t go back!

If you aren’t satisfied with the build tool and configuration choices, you can eject at any time. This command will remove the single build dependency from your project.

Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except eject will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own.

You don’t have to ever use eject. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it.

Learn More

You can learn more in the Create React App documentation.

To learn React, check out the React documentation.

About

react hook应用,优化代码,提升性能,自定义loader、plugin,开发库组件,利用webpack打包进行优化,微前端的应用


Languages

Language:TypeScript 87.0%Language:JavaScript 8.3%Language:HTML 3.8%Language:CSS 0.6%Language:Shell 0.4%