- 创建基本框架
$ mkdir app && cd ./app
$ mkdir public src && cd ./src
$ mkdir api assets components config pages utils
||
npx create-react-app yourProjectName --template typescript
- 编写 package.json
{
"name": "jira_new",
"version": "0.1.0",
"private": true,
"dependencies": {
"@craco/craco": "^6.4.3",
"@emotion/react": "^11.7.1",
"@emotion/styled": "^11.6.0",
"@testing-library/jest-dom": "^5.16.2",
"@testing-library/react": "^12.1.2",
"@testing-library/user-event": "^13.5.0",
"@types/jest": "^27.4.0",
"@types/node": "^16.11.22",
"@types/react": "^17.0.39",
"@types/react-dom": "^17.0.11",
"antd": "^4.18.2",
"axios": "^0.24.0",
"craco-less": "^2.0.0",
"dayjs": "^1.10.7",
"jsonp": "^0.2.1",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-scripts": "5.0.0",
"store": "^2.0.12",
"typescript": "^4.5.5",
"web-vitals": "^2.1.4"
},
"scripts": {
"start": "craco start",
"build": "craco build",
"test": "craco test",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": [
"react-app",
"react-app/jest"
]
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
}
}
- 在项目跟路径下编写 craco.config.ts
const CracoLessPlugin = require('craco-less');
module.exports = {
plugins: [
{
plugin: CracoLessPlugin,
options: {
lessLoaderOptions: {
lessOptions: {
modifyVars: { '@primary-color': '#1DA57A' },
javascriptEnabled: true,
},
},
},
},
],
};
- 在public下创建一个空的 index.html 文件并且加一个div#root
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>React项目</title>
</head>
<body>
<div id="root"></div>
</body>
</html>
我猜估计没人学到这里还会去手写上面的代码吧!!!
- 编写 App.tsx
import React, { Component } from 'react'
export default class App extends Component {
render() {
return (
<div>
App
</div>
)
}
}
- 编写 index.ts
import React from 'react';
import ReactDOM from 'react-dom'
import App from './App'
ReactDOM.render(<App/>,document.getElementById('root'))
- 保证你安装了node.js执行以下命令
$ npm i yarn -g
$ yarn
$ yarn start
jira 项目后台
yarn add jira-dev-tool@1.7.61
npx msw init ./public