fix(web): 调整样式加载与 UnoCSS 配置并更新构建文档
This commit is contained in:
1 parent
eeae0af978
commit
09593b221b
5 files changed
+10
-13
No files matched your search
@@ -933,15 +933,16 @@ FATAL ERROR: Reached heap limit Allocation failed - JavaScript heap out of memor
|
||||
```json
|
||||
{
|
||||
"scripts": {
|
||||
"build:prod": "node --max-old-space-size=8192 node_modules/vite/bin/vite.js build --mode production",
|
||||
"build:dev": "node --max-old-space-size=8192 node_modules/vite/bin/vite.js build --mode development"
|
||||
"build:prod": "node --max-old-space-size=6144 node_modules/vite/bin/vite.js build --mode production",
|
||||
"build:dev": "node --max-old-space-size=6144 node_modules/vite/bin/vite.js build --mode development"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
#### 参数说明
|
||||
- `--max-old-space-size=8192`:设置堆内存限制为8GB
|
||||
- 可根据项目规模和机器内存调整数值(4096=4GB, 8192=8GB)
|
||||
- `--max-old-space-size=6144`:设置堆内存限制为 6GB
|
||||
- 可根据项目规模和机器内存调整数值(4096=4GB, 6144=6GB, 8192=8GB)
|
||||
- 2026-10-21:4096MB 会在生产构建 transform 约 2400 个模块时 OOM。当前开发机物理内存为 8GB,脚本使用 6144MB,避免堆上限等于整机内存
|
||||
|
||||
#### 适用场景
|
||||
- 大型前端项目构建
|
||||
|
||||
@@ -37,6 +37,8 @@ npm install
|
||||
npm run build:prod
|
||||
```
|
||||
|
||||
构建脚本将 Node 堆上限设为 6144MB。4096MB 会在 transform 阶段被活对象占满(约 4091MB,GC 几乎无法回收)并报 `JavaScript heap out of memory`。本机物理内存为 8GB,因此不用 8192MB。同时限制 Rollup 并行读文件数,避免打包时把文件一次性读进内存。Element Plus 与 animate.css 改为普通 CSS 引入,不再经由 Sass 编译。构建已关闭控制台 gzip 体积统计,且小于 10KB 的分包不再预生成 `.gz`(较大的 js/css 仍会生成,供 nginx `gzip_static` 使用)。Element Plus 样式全量引入,打包时不再按组件重复引入样式。
|
||||
|
||||
### 步骤2:验证构建产物
|
||||
|
||||
```bash
|
||||
|
||||
@@ -12,8 +12,6 @@
|
||||
@use './sidebar.scss';
|
||||
@use './btn.scss';
|
||||
@use './ruoyi.scss';
|
||||
@use 'animate.css';
|
||||
@use 'element-plus/dist/index.css';
|
||||
|
||||
body {
|
||||
height: 100%;
|
||||
|
||||
@@ -2,6 +2,8 @@ import { translateRouteTitle } from './utils/i18n';
|
||||
import { createApp } from 'vue';
|
||||
// global css
|
||||
import 'virtual:uno.css';
|
||||
import 'element-plus/dist/index.css';
|
||||
import 'animate.css';
|
||||
import '@/assets/styles/index.scss';
|
||||
import 'element-plus/theme-chalk/dark/css-vars.css';
|
||||
|
||||
|
||||
+1
-7
@@ -1,10 +1,8 @@
|
||||
import {
|
||||
defineConfig,
|
||||
presetAttributify,
|
||||
presetIcons,
|
||||
presetTypography,
|
||||
presetUno,
|
||||
presetWebFonts,
|
||||
transformerDirectives,
|
||||
transformerVariantGroup
|
||||
} from 'unocss';
|
||||
@@ -23,11 +21,7 @@ export default defineConfig({
|
||||
presets: [
|
||||
presetUno(),
|
||||
presetAttributify(),
|
||||
presetIcons(),
|
||||
presetTypography(),
|
||||
presetWebFonts({
|
||||
fonts: {}
|
||||
})
|
||||
presetTypography()
|
||||
],
|
||||
transformers: [transformerDirectives(), transformerVariantGroup()]
|
||||
});
|
||||
Reference in new issue
Block a user