Skip to content

Commit 102ddf8

Browse files
committed
Merge remote-tracking branch 'origin/rsbuild'
2 parents 14e94ee + c5569ba commit 102ddf8

33 files changed

Lines changed: 1800 additions & 172 deletions

.github/workflows/deploy.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
run: yarn
2323

2424
- name: Build project
25-
run: yarn build:prod
25+
run: yarn build
2626

2727
- name: Add known hosts
2828
run: |

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
# Nexus
1+
# Nexus-Admin Rsbuild分支
22

3-
4-
# 集成信息管理平台,用于将多种协议、多种系统进行耦合,通过配置服务并发布,可做到让不同厂商的系统进行最简化的系统对接
3+
# 项目介绍
4+
Nexus-Admin 是一个基于 React 19.1.9 版本的管理系统,使用 Rsbuild 构建工具,基于 Ant Design 组件库,采用 TypeScript 编写。该项目的主要功能是集成信息管理平台,用于将多种协议、多种系统进行耦合,通过配置服务并发布,可做到让不同厂商的系统进行最简化的系统对接
55

66
# 框架技术:
77
- react@19.1.9
88
- antd@latest
9-
- vite@latest 构建工具
9+
- rsbuild@latest 构建工具
1010
- zustand@latest 状态管理
1111
- sass@latest
1212
- react-router@latest

biome.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,4 +52,8 @@
5252
}
5353
}
5454
}
55+
<<<<<<< HEAD
5556
}
57+
=======
58+
}
59+
>>>>>>> origin/rsbuild

bun.lock

Lines changed: 680 additions & 28 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

index.html

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,5 @@
1414
</strong>
1515
</noscript>
1616
<div id="root"></div>
17-
<script type="module" src="/src/main.tsx"></script>
1817
</body>
1918
</html>

mock/login.mock.ts

Lines changed: 706 additions & 0 deletions
Large diffs are not rendered by default.

package.json

Lines changed: 33 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
{
22
"name": "nexus-admin",
3+
"version": "0.0.1",
34
"private": true,
4-
"version": "0.0.0",
55
"type": "module",
66
"scripts": {
7-
"dev": "vite",
8-
"build": "tsc -b && vite build",
9-
"build:prod": "vite build --mode production",
10-
"lint": "eslint .",
11-
"preview": "vite preview"
7+
"build": "rsbuild build",
8+
"check": "biome check --write",
9+
"dev": "rsbuild dev",
10+
"format": "biome format --write",
11+
"preview": "rsbuild preview",
12+
"dev:rsdoctor": "RSDOCTOR=true rsbuild dev",
13+
"build:rsdoctor": "RSDOCTOR=true rsbuild build"
1214
},
1315
"dependencies": {
1416
"@ant-design/v5-patch-for-react-19": "^1.0.3",
@@ -38,24 +40,41 @@
3840
"react-hotkeys-hook": "^5.1.0",
3941
"react-i18next": "^15.6.1",
4042
"react-is": "^19.1.1",
43+
<<<<<<< HEAD
4144
"react-router": "7.8.1",
45+
=======
46+
"react-router": "^7.8.1",
47+
>>>>>>> origin/rsbuild
4248
"screenfull": "^6.0.2",
4349
"tailwind-merge": "^3.3.1",
4450
"zustand": "^5.0.7"
4551
},
4652
"devDependencies": {
53+
<<<<<<< HEAD
4754
"@biomejs/biome": "2.2.0",
4855
"@iconify-icon/react": "^3.0.0",
4956
"@tailwindcss/vite": "^4.1.12",
57+
=======
58+
"@biomejs/biome": "^2.2.0",
59+
"@iconify-icon/react": "^3.0.0",
60+
"@rsbuild/core": "^1.4.15",
61+
"@rsbuild/plugin-babel": "^1.0.6",
62+
"@rsbuild/plugin-image-compress": "^1.3.1",
63+
"@rsbuild/plugin-react": "^1.3.5",
64+
"@rsbuild/plugin-sass": "^1.3.4",
65+
"@rsbuild/plugin-svgr": "^1.2.2",
66+
"@rsdoctor/rspack-plugin": "^1.2.2",
67+
"@tailwindcss/postcss": "^4.1.12",
68+
>>>>>>> origin/rsbuild
5069
"@types/crypto-js": "^4.2.2",
5170
"@types/lodash-es": "^4.17.12",
5271
"@types/node": "^22.17.2",
5372
"@types/react": "^19.1.10",
5473
"@types/react-dom": "^19.1.7",
5574
"@types/react-is": "^19.0.0",
5675
"@types/react-resizable": "^3.0.8",
57-
"@vitejs/plugin-react": "^5.0.0",
5876
"babel-plugin-react-compiler": "^19.1.0-rc.2",
77+
<<<<<<< HEAD
5978
"globals": "^16.3.0",
6079
"sass-embedded": "^1.90.0",
6180
"tailwindcss": "^4.1.12",
@@ -64,8 +83,14 @@
6483
"vite": "npm:rolldown-vite@7.1.2",
6584
"vite-plugin-compression": "^0.5.1",
6685
"vite-plugin-mock-dev-server": "^1.9.3"
86+
=======
87+
"rsbuild-plugin-html-minifier-terser": "^1.1.2",
88+
"rspack-plugin-mock": "^1.2.0",
89+
"tailwindcss": "^4.1.12",
90+
"typescript": "^5.9.2"
91+
>>>>>>> origin/rsbuild
6792
},
6893
"engines": {
6994
"node": ">=22.12.0"
7095
}
71-
}
96+
}

postcss.config.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
export default {
2+
plugins: {
3+
"@tailwindcss/postcss": {},
4+
},
5+
};

rsbuild.config.ts

Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
import path from 'node:path';
2+
import { pluginHtmlMinifierTerser } from 'rsbuild-plugin-html-minifier-terser';
3+
import { pluginMockServer } from 'rspack-plugin-mock/rsbuild';
4+
import { defineConfig } from '@rsbuild/core';
5+
import { pluginImageCompress } from '@rsbuild/plugin-image-compress';
6+
import { pluginBabel } from '@rsbuild/plugin-babel';
7+
import { pluginReact } from '@rsbuild/plugin-react';
8+
import { pluginSvgr } from '@rsbuild/plugin-svgr';
9+
import { pluginSass } from '@rsbuild/plugin-sass';
10+
11+
const isDev = process.env.NODE_ENV === 'development';
12+
13+
export default defineConfig({
14+
plugins: [
15+
// 表示将react和router相关的包拆分为单独的chunk
16+
pluginReact({
17+
splitChunks: {
18+
react: true,
19+
router: true,
20+
},
21+
}),
22+
pluginBabel({
23+
include: /\.(?:jsx|tsx)$/,
24+
babelLoaderOptions(opts) {
25+
opts.plugins?.unshift('babel-plugin-react-compiler');
26+
},
27+
}),
28+
// 将SVG转换为React组件
29+
pluginSvgr(),
30+
pluginSass({
31+
// sass文件默认注入全局的变量文件
32+
sassLoaderOptions: {
33+
additionalData: `@use 'src/styles/variables.scss' as *;`,
34+
},
35+
}),
36+
// mock 插件
37+
pluginMockServer({
38+
// 表示拦截以路径/api开头的
39+
prefix: '/api',
40+
}),
41+
// 启动图片压缩
42+
pluginImageCompress(),
43+
// 启动html压缩
44+
pluginHtmlMinifierTerser({
45+
collapseBooleanAttributes: true,
46+
collapseInlineTagWhitespace: true,
47+
collapseWhitespace: true,
48+
minifyCSS: true,
49+
minifyJS: true,
50+
}),
51+
],
52+
// 配置html模板
53+
html: {
54+
template: './index.html',
55+
},
56+
// 配置路径别名
57+
resolve: {
58+
alias: {
59+
'@': path.resolve(__dirname, './src'),
60+
// 将三方依赖中对lodash的依赖重定向到lodash-es
61+
lodash: 'lodash-es',
62+
'lodash-es': path.resolve(__dirname, 'node_modules/lodash-es'),
63+
react: path.resolve(__dirname, 'node_modules/react'),
64+
},
65+
extensions: ['.js', '.jsx', '.ts', '.tsx', '.json'],
66+
// 通过rsdcotor分析出来的打包时重复包
67+
dedupe: ['@babel/runtime', 'tslib', 'rc-switch', 'rc-checkbox', 'clsx', 'react-is'],
68+
},
69+
dev: {
70+
// 按需编译
71+
lazyCompilation: true,
72+
// 启用热更新
73+
hmr: true,
74+
// 显示编译进度条
75+
// progressBar: true,
76+
},
77+
// 构建产物相关配置
78+
output: {
79+
sourceMap: {
80+
js: isDev ? 'cheap-module-source-map' : false, // 开发环境开启js的sourceMap
81+
css: isDev,
82+
},
83+
cleanDistPath: true, // 每次构建前清理dist目录
84+
charset: 'utf8', // 设置输出文件的编码
85+
},
86+
source: {
87+
// 配置装饰器语法用于支持@injectable()和@inject装饰器
88+
decorators: {
89+
version: 'legacy',
90+
},
91+
},
92+
93+
// 构建优化相关
94+
performance: {
95+
chunkSplit: {
96+
strategy: 'split-by-experience',
97+
// 下面的部分单独分包(这里暂时不分包-原因是:后续的测试中发现不配置下面的选项页面加载反而更快)
98+
forceSplitting: {
99+
axios: /node_modules[\\/]axios/,
100+
antd: /node_modules[\\/]antd/,
101+
// echarts: /node_modules[\\/]echarts/,
102+
// zrender: /node_modules[\\/]zrender/,
103+
// antdIcons: /node_modules[\\/]@ant-design\/icons/,
104+
// 'rc-cp': /node_modules[\\/]rc-/,
105+
},
106+
},
107+
// 启用构建缓存
108+
buildCache: !isDev,
109+
// 移除console.[method]语句
110+
removeConsole: true,
111+
// 开启包文件分析
112+
// bundleAnalyze: {
113+
// openAnalyzer: isDev, // 是否开启包文件分析,现在仅在开发环境下开启
114+
// analyzerMode: 'static',
115+
// reportFilename: 'bundle-report.html',
116+
// },
117+
},
118+
// 服务相关
119+
server: {
120+
port: 8000,
121+
proxy: {
122+
'/api': {
123+
target: 'http://localhost:9193',
124+
changeOrigin: true,
125+
pathRewrite: (path) => path.replace(/^\/api/, ''),
126+
},
127+
},
128+
},
129+
});

src/App.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ const App: React.FC = () => {
3737
antdUtils.setModalInstance(modal);
3838

3939
if (!isLogin || location.pathname === '/login') {
40-
navigate('/login');
40+
navigate('/login', { replace: true });
4141
} else {
4242
// 查询菜单数据
4343
refetch();

0 commit comments

Comments
 (0)