perf(web): 降低生产构建内存峰值,并启用 CI 低内存打包模式
关闭按需 Element Plus 样式与构建期 dts、限制 rollup 并行、CI 跳过 gzip; 新增 npm run build:ci,供 Drone 在小内存机器上打包。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
df6ce133dd
commit
9d93a373ae
8 files changed
+55
-27
No files matched your search
@@ -1,16 +1,20 @@
|
||||
import compression from 'vite-plugin-compression';
|
||||
|
||||
export default (env: any) => {
|
||||
const { VITE_BUILD_COMPRESS } = env;
|
||||
// CI 可通过空值或空格关闭:VITE_BUILD_COMPRESS=
|
||||
const raw = String(env?.VITE_BUILD_COMPRESS ?? '').trim();
|
||||
const plugin: any[] = [];
|
||||
if (VITE_BUILD_COMPRESS) {
|
||||
const compressList = VITE_BUILD_COMPRESS.split(',');
|
||||
if (raw) {
|
||||
const compressList = raw.split(',').map((s: string) => s.trim()).filter(Boolean);
|
||||
if (compressList.includes('gzip')) {
|
||||
// http://doc.ruoyi.vip/ruoyi-vue/other/faq.html#使用gzip解压缩静态文件
|
||||
plugin.push(
|
||||
compression({
|
||||
ext: '.gz',
|
||||
deleteOriginFile: false
|
||||
deleteOriginFile: false,
|
||||
// 小于 10KB 的分包压缩收益很小,跳过可明显缩短收尾时间
|
||||
threshold: 10 * 1024,
|
||||
verbose: false
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user