feat: 引入vite-react-app项目作为常用的后台方案
This commit is contained in:
parent
e741a019c7
commit
eaba2f1bca
|
@ -9,6 +9,7 @@
|
||||||
"preview": "vite preview"
|
"preview": "vite preview"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"@backset/ui": "workspace:^1.0.0",
|
||||||
"antd": "^5.2.0",
|
"antd": "^5.2.0",
|
||||||
"less": "^4.1.3",
|
"less": "^4.1.3",
|
||||||
"react": "^18.2.0",
|
"react": "^18.2.0",
|
||||||
|
@ -20,6 +21,7 @@
|
||||||
"@types/react-dom": "^18.0.10",
|
"@types/react-dom": "^18.0.10",
|
||||||
"@types/react-router-dom": "5.3.3",
|
"@types/react-router-dom": "5.3.3",
|
||||||
"@vitejs/plugin-react": "^3.1.0",
|
"@vitejs/plugin-react": "^3.1.0",
|
||||||
|
"vite-tsconfig-paths": "4.0.5",
|
||||||
"typescript": "^4.9.3",
|
"typescript": "^4.9.3",
|
||||||
"vite": "^4.1.0"
|
"vite": "^4.1.0"
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,14 @@
|
||||||
import { Button, message } from "antd";
|
import { Button, message } from "antd";
|
||||||
|
import { useArticle } from "@backset/ui";
|
||||||
|
import { useMount } from "../../hooks";
|
||||||
|
|
||||||
export default function Index() {
|
export default function Index() {
|
||||||
|
useMount(() => {
|
||||||
|
console.log(useArticle());
|
||||||
|
});
|
||||||
|
|
||||||
const onClick = () => {
|
const onClick = () => {
|
||||||
message.info("hi");
|
message.info(`hi, 很惆怅啊, vite 哪里又有坑哦`);
|
||||||
};
|
};
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
import { defineConfig } from 'vite'
|
import { defineConfig } from "vite";
|
||||||
import react from '@vitejs/plugin-react'
|
import react from "@vitejs/plugin-react";
|
||||||
|
import tsconfigPaths from "vite-tsconfig-paths";
|
||||||
|
|
||||||
// https://vitejs.dev/config/
|
// https://vitejs.dev/config/
|
||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
plugins: [react()],
|
plugins: [react(), tsconfigPaths()],
|
||||||
})
|
});
|
||||||
|
|
|
@ -4,7 +4,8 @@
|
||||||
"description": "",
|
"description": "",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev:apps-server": "cd apps/server && pnpm start:dev"
|
"dev:apps-server": "cd apps/server && pnpm start:dev",
|
||||||
|
"dev:apps-admin": "cd apps/admin && pnpm dev"
|
||||||
},
|
},
|
||||||
"keywords": [],
|
"keywords": [],
|
||||||
"author": "",
|
"author": "",
|
||||||
|
|
|
@ -6,7 +6,5 @@
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "rimraf ./dist && tsc -p ./tsconfig.build.json"
|
"build": "rimraf ./dist && tsc -p ./tsconfig.build.json"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {}
|
||||||
"md5.js": "1.3.5"
|
|
||||||
}
|
|
||||||
}
|
}
|
1968
pnpm-lock.yaml
1968
pnpm-lock.yaml
File diff suppressed because it is too large
Load Diff
15
readme.md
15
readme.md
|
@ -128,6 +128,21 @@ webpack 负责构建,根据 esmodule、commonjs 规范,找到对应的依赖
|
||||||
|
|
||||||
esbuild 同 webpack 一样,速度更快,但是 production 稳定性待考究
|
esbuild 同 webpack 一样,速度更快,但是 production 稳定性待考究
|
||||||
|
|
||||||
|
# 坑点
|
||||||
|
|
||||||
|
## vite 项目引包报错
|
||||||
|
|
||||||
|
能够直接读取 tsconfig.json 并使用同样的路径解析方式。用这个插件替换掉上面的 alias 配置就能保证路径解析规则在 vite 和 create-react-app 环境中保持一致。
|
||||||
|
|
||||||
|
```js
|
||||||
|
import tsconfigPaths from "vite-tsconfig-paths";
|
||||||
|
|
||||||
|
// https://vitejs.dev/config/
|
||||||
|
export default defineConfig({
|
||||||
|
plugins: [react(), tsconfigPaths()],
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
||||||
# 待解决的问题
|
# 待解决的问题
|
||||||
|
|
||||||
## 自动化编译构建依赖
|
## 自动化编译构建依赖
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
"strictNullChecks": true,
|
"strictNullChecks": true,
|
||||||
"baseUrl": ".",
|
"baseUrl": ".",
|
||||||
"paths": {
|
"paths": {
|
||||||
"@demo/*": [
|
"@backset/*": [
|
||||||
"packages/*/src" // packages/*/src/index.ts 作为入口文件常规操作
|
"packages/*/src" // packages/*/src/index.ts 作为入口文件常规操作
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user