feat: oyouhua build
This commit is contained in:
+1
-1
@@ -9,7 +9,7 @@
|
||||
"serve:prod": "vite --mode production",
|
||||
"build:dev": "vue-tsc --noEmit && vite build --mode development",
|
||||
"build:test": "vue-tsc --noEmit && vite build --mode test",
|
||||
"build:prod": "vite build --mode production",
|
||||
"build:prod": "node --max-old-space-size=4096 ./node_modules/vite/bin/vite.js build --mode production",
|
||||
"test": "vitest",
|
||||
"test:run": "vitest run",
|
||||
"test:coverage": "vitest run --coverage",
|
||||
|
||||
@@ -1,10 +1,22 @@
|
||||
import { defineComponent, ref, nextTick } from 'vue';
|
||||
import { DatePicker, Select, Table } from 'ant-design-vue';
|
||||
import * as echarts from 'echarts';
|
||||
import * as echarts from 'echarts/core';
|
||||
import { BarChart, LineChart } from 'echarts/charts';
|
||||
import { GridComponent, TooltipComponent, LegendComponent } from 'echarts/components';
|
||||
import { CanvasRenderer } from 'echarts/renderers';
|
||||
import { useReportsModel } from './model/useReportsModel';
|
||||
import { useEffect, useContainerSize } from '@/hooks';
|
||||
import styles from './index.module.less';
|
||||
|
||||
echarts.use([
|
||||
BarChart,
|
||||
LineChart,
|
||||
GridComponent,
|
||||
TooltipComponent,
|
||||
LegendComponent,
|
||||
CanvasRenderer,
|
||||
]);
|
||||
|
||||
const { RangePicker } = DatePicker;
|
||||
|
||||
/**
|
||||
|
||||
+15
-3
@@ -7,6 +7,12 @@ import { resolve } from 'path';
|
||||
|
||||
// https://vitejs.dev/config/
|
||||
export default defineConfig(({ mode }) => {
|
||||
// 增大 Node 内存限制,防止构建时 OOM
|
||||
const v8Flags = '--max-old-space-size=4096';
|
||||
if (!process.env.NODE_OPTIONS?.includes('max-old-space-size')) {
|
||||
process.env.NODE_OPTIONS = [process.env.NODE_OPTIONS, v8Flags].filter(Boolean).join(' ');
|
||||
}
|
||||
|
||||
const env = loadEnv(mode, process.cwd(), '');
|
||||
const isProd = mode === 'production';
|
||||
|
||||
@@ -54,12 +60,10 @@ export default defineConfig(({ mode }) => {
|
||||
build: {
|
||||
outDir: 'dist',
|
||||
sourcemap: mode !== 'production',
|
||||
// 生产构建移除 console 和注释(esbuild minify 阶段)
|
||||
minify: isProd ? 'esbuild' : false,
|
||||
chunkSizeWarningLimit: 1500,
|
||||
rollupOptions: {
|
||||
output: {
|
||||
// 更细粒度的分包,确保按需加载
|
||||
manualChunks(id) {
|
||||
if (id.includes('node_modules')) {
|
||||
if (id.includes('ant-design-vue') || id.includes('@ant-design')) {
|
||||
@@ -68,7 +72,15 @@ export default defineConfig(({ mode }) => {
|
||||
if (id.includes('vue') || id.includes('@vue') || id.includes('vue-router')) {
|
||||
return 'vue-vendor';
|
||||
}
|
||||
// 其他第三方依赖单独打包,未使用的不会进入
|
||||
if (id.includes('echarts')) {
|
||||
return 'echarts';
|
||||
}
|
||||
if (id.includes('china-area-data')) {
|
||||
return 'area-data';
|
||||
}
|
||||
if (id.includes('big.js')) {
|
||||
return 'bigjs';
|
||||
}
|
||||
return 'vendor';
|
||||
}
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user