升级到vite3,据说能提升首屏性能,但感觉不明显
parent
78fa18f5aa
commit
3c3353da4f
|
@ -1,13 +1,13 @@
|
||||||
import { createProdMockServer } from 'vite-plugin-mock/es/createProdMockServer';
|
import { createProdMockServer } from 'vite-plugin-mock/es/createProdMockServer';
|
||||||
|
|
||||||
const modules = import.meta.globEager('./**/*.ts');
|
const modules = import.meta.glob('./**/*.ts', { eager: true });
|
||||||
|
|
||||||
const mockModules: any[] = [];
|
const mockModules: any[] = [];
|
||||||
Object.keys(modules).forEach((key) => {
|
Object.keys(modules).forEach((key) => {
|
||||||
if (key.includes('/_')) {
|
if (key.includes('/_')) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
mockModules.push(...modules[key].default);
|
mockModules.push(...(modules as Recordable)[key].default);
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
17
package.json
17
package.json
|
@ -34,6 +34,7 @@
|
||||||
"gen:icon": "esno ./build/generate/icon/index.ts"
|
"gen:icon": "esno ./build/generate/icon/index.ts"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"terser": "^5.14.2",
|
||||||
"@jeecg/online": "3.4.3-GA",
|
"@jeecg/online": "3.4.3-GA",
|
||||||
"@iconify/iconify": "^2.2.1",
|
"@iconify/iconify": "^2.2.1",
|
||||||
"@ant-design/colors": "^6.0.0",
|
"@ant-design/colors": "^6.0.0",
|
||||||
|
@ -45,7 +46,7 @@
|
||||||
"@vueuse/shared": "^8.3.0",
|
"@vueuse/shared": "^8.3.0",
|
||||||
"@vueuse/core": "^8.3.0",
|
"@vueuse/core": "^8.3.0",
|
||||||
"@zxcvbn-ts/core": "^2.0.1",
|
"@zxcvbn-ts/core": "^2.0.1",
|
||||||
"ant-design-vue": "3.2.12",
|
"ant-design-vue": "^3.2.12",
|
||||||
"axios": "^0.26.1",
|
"axios": "^0.26.1",
|
||||||
"china-area-data": "^5.0.1",
|
"china-area-data": "^5.0.1",
|
||||||
"clipboard": "^2.0.8",
|
"clipboard": "^2.0.8",
|
||||||
|
@ -111,8 +112,8 @@
|
||||||
"@types/sortablejs": "^1.10.7",
|
"@types/sortablejs": "^1.10.7",
|
||||||
"@typescript-eslint/eslint-plugin": "^5.20.0",
|
"@typescript-eslint/eslint-plugin": "^5.20.0",
|
||||||
"@typescript-eslint/parser": "^5.20.0",
|
"@typescript-eslint/parser": "^5.20.0",
|
||||||
"@vitejs/plugin-legacy": "^1.8.1",
|
"@vitejs/plugin-legacy": "^2.0.0",
|
||||||
"@vitejs/plugin-vue": "^2.3.1",
|
"@vitejs/plugin-vue": "^3.0.1",
|
||||||
"@vitejs/plugin-vue-jsx": "^1.3.10",
|
"@vitejs/plugin-vue-jsx": "^1.3.10",
|
||||||
"@vue/compiler-sfc": "^3.2.33",
|
"@vue/compiler-sfc": "^3.2.33",
|
||||||
"@vue/test-utils": "^2.0.0-rc.21",
|
"@vue/test-utils": "^2.0.0-rc.21",
|
||||||
|
@ -157,21 +158,21 @@
|
||||||
"ts-jest": "^27.0.7",
|
"ts-jest": "^27.0.7",
|
||||||
"ts-node": "^10.7.0",
|
"ts-node": "^10.7.0",
|
||||||
"typescript": "^4.6.3",
|
"typescript": "^4.6.3",
|
||||||
"vite": "^2.9.5",
|
"vite": "^3.0.2",
|
||||||
"vite-plugin-compression": "^0.5.1",
|
"vite-plugin-compression": "^0.5.1",
|
||||||
"vite-plugin-html": "^3.2.0",
|
"vite-plugin-html": "^3.2.0",
|
||||||
"vite-plugin-imagemin": "^0.6.1",
|
"vite-plugin-imagemin": "^0.6.1",
|
||||||
"vite-plugin-mkcert": "1.6.0",
|
"vite-plugin-mkcert": "^1.9.0",
|
||||||
"vite-plugin-mock": "^2.9.6",
|
"vite-plugin-mock": "^2.9.6",
|
||||||
"vite-plugin-optimize-persist": "^0.1.2",
|
"vite-plugin-optimize-persist": "^0.1.2",
|
||||||
"vite-plugin-package-config": "^0.1.1",
|
"vite-plugin-package-config": "^0.1.1",
|
||||||
"vite-plugin-purge-icons": "^0.8.1",
|
"vite-plugin-purge-icons": "^0.8.2",
|
||||||
"vite-plugin-pwa": "^0.11.13",
|
"vite-plugin-pwa": "^0.12.3",
|
||||||
"vite-plugin-style-import": "^2.0.0",
|
"vite-plugin-style-import": "^2.0.0",
|
||||||
"vite-plugin-svg-icons": "^2.0.1",
|
"vite-plugin-svg-icons": "^2.0.1",
|
||||||
"vite-plugin-theme": "^0.8.6",
|
"vite-plugin-theme": "^0.8.6",
|
||||||
"vite-plugin-vue-setup-extend": "^0.4.0",
|
"vite-plugin-vue-setup-extend": "^0.4.0",
|
||||||
"vite-plugin-windicss": "^1.8.4",
|
"vite-plugin-windicss": "^1.8.7",
|
||||||
"vue-eslint-parser": "^8.3.0",
|
"vue-eslint-parser": "^8.3.0",
|
||||||
"vue-tsc": "^0.33.9"
|
"vue-tsc": "^0.33.9"
|
||||||
},
|
},
|
||||||
|
|
|
@ -2,10 +2,10 @@ import { genMessage } from '../helper';
|
||||||
import antdLocale from 'ant-design-vue/es/locale/en_US';
|
import antdLocale from 'ant-design-vue/es/locale/en_US';
|
||||||
//import momentLocale from 'moment/dist/locale/eu';
|
//import momentLocale from 'moment/dist/locale/eu';
|
||||||
|
|
||||||
const modules = import.meta.globEager('./en/**/*.ts');
|
const modules = import.meta.glob('./en/**/*.ts', { eager: true });
|
||||||
export default {
|
export default {
|
||||||
message: {
|
message: {
|
||||||
...genMessage(modules, 'en'),
|
...genMessage(modules as Recordable<Recordable>, 'en'),
|
||||||
antdLocale,
|
antdLocale,
|
||||||
},
|
},
|
||||||
dateLocale: null,
|
dateLocale: null,
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
import { genMessage } from '../helper';
|
import { genMessage } from '../helper';
|
||||||
import antdLocale from 'ant-design-vue/es/locale/zh_CN';
|
import antdLocale from 'ant-design-vue/es/locale/zh_CN';
|
||||||
|
|
||||||
const modules = import.meta.globEager('./zh-CN/**/*.ts');
|
const modules = import.meta.glob('./zh-CN/**/*.ts', { eager: true });
|
||||||
export default {
|
export default {
|
||||||
message: {
|
message: {
|
||||||
...genMessage(modules, 'zh-CN'),
|
...genMessage(modules as Recordable<Recordable>, 'zh-CN'),
|
||||||
antdLocale,
|
antdLocale,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
|
@ -10,12 +10,12 @@ import { router } from '/@/router';
|
||||||
import { PermissionModeEnum } from '/@/enums/appEnum';
|
import { PermissionModeEnum } from '/@/enums/appEnum';
|
||||||
import { pathToRegexp } from 'path-to-regexp';
|
import { pathToRegexp } from 'path-to-regexp';
|
||||||
|
|
||||||
const modules = import.meta.globEager('./modules/**/*.ts');
|
const modules = import.meta.glob('./modules/**/*.ts', { eager: true });
|
||||||
|
|
||||||
const menuModules: MenuModule[] = [];
|
const menuModules: MenuModule[] = [];
|
||||||
|
|
||||||
Object.keys(modules).forEach((key) => {
|
Object.keys(modules).forEach((key) => {
|
||||||
const mod = modules[key].default || {};
|
const mod = (modules as Recordable)[key].default || {};
|
||||||
const modList = Array.isArray(mod) ? [...mod] : [mod];
|
const modList = Array.isArray(mod) ? [...mod] : [mod];
|
||||||
menuModules.push(...modList);
|
menuModules.push(...modList);
|
||||||
});
|
});
|
||||||
|
|
|
@ -6,12 +6,13 @@ import { mainOutRoutes } from './mainOut';
|
||||||
import { PageEnum } from '/@/enums/pageEnum';
|
import { PageEnum } from '/@/enums/pageEnum';
|
||||||
import { t } from '/@/hooks/web/useI18n';
|
import { t } from '/@/hooks/web/useI18n';
|
||||||
|
|
||||||
const modules = import.meta.globEager('./modules/**/*.ts');
|
const modules = import.meta.glob('./modules/**/*.ts', { eager: true });
|
||||||
|
|
||||||
const routeModuleList: AppRouteModule[] = [];
|
const routeModuleList: AppRouteModule[] = [];
|
||||||
|
|
||||||
|
// 加入到路由集合中
|
||||||
Object.keys(modules).forEach((key) => {
|
Object.keys(modules).forEach((key) => {
|
||||||
const mod = modules[key].default || {};
|
const mod = (modules as Recordable)[key].default || {};
|
||||||
const modList = Array.isArray(mod) ? [...mod] : [mod];
|
const modList = Array.isArray(mod) ? [...mod] : [mod];
|
||||||
routeModuleList.push(...modList);
|
routeModuleList.push(...modList);
|
||||||
});
|
});
|
||||||
|
|
|
@ -3,7 +3,6 @@ import pkg from './package.json';
|
||||||
import dayjs from 'dayjs';
|
import dayjs from 'dayjs';
|
||||||
import { loadEnv } from 'vite';
|
import { loadEnv } from 'vite';
|
||||||
import { resolve } from 'path';
|
import { resolve } from 'path';
|
||||||
//require('vue-jeecg-plugs/packages/utils')
|
|
||||||
import { generateModifyVars } from './build/generate/generateModifyVars';
|
import { generateModifyVars } from './build/generate/generateModifyVars';
|
||||||
import { createProxy } from './build/vite/proxy';
|
import { createProxy } from './build/vite/proxy';
|
||||||
import { wrapperEnv } from './build/utils';
|
import { wrapperEnv } from './build/utils';
|
||||||
|
@ -62,9 +61,7 @@ export default ({ command, mode }: ConfigEnv): UserConfig => {
|
||||||
proxy: createProxy(VITE_PROXY),
|
proxy: createProxy(VITE_PROXY),
|
||||||
},
|
},
|
||||||
build: {
|
build: {
|
||||||
minify: 'terser',
|
|
||||||
target: 'es2015',
|
target: 'es2015',
|
||||||
// 【VUEN-872】css编译兼容低版本chrome内核(例如360浏览器)
|
|
||||||
cssTarget: 'chrome80',
|
cssTarget: 'chrome80',
|
||||||
outDir: OUTPUT_DIR,
|
outDir: OUTPUT_DIR,
|
||||||
terserOptions: {
|
terserOptions: {
|
||||||
|
@ -72,10 +69,11 @@ export default ({ command, mode }: ConfigEnv): UserConfig => {
|
||||||
keep_infinity: true,
|
keep_infinity: true,
|
||||||
// Used to delete console in production environment
|
// Used to delete console in production environment
|
||||||
drop_console: VITE_DROP_CONSOLE,
|
drop_console: VITE_DROP_CONSOLE,
|
||||||
|
drop_debugger: true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
// Turning off brotliSize display can slightly reduce packaging time
|
// Turning off brotliSize display can slightly reduce packaging time
|
||||||
brotliSize: false,
|
reportCompressedSize: false,
|
||||||
chunkSizeWarningLimit: 2000,
|
chunkSizeWarningLimit: 2000,
|
||||||
},
|
},
|
||||||
define: {
|
define: {
|
||||||
|
@ -83,6 +81,10 @@ export default ({ command, mode }: ConfigEnv): UserConfig => {
|
||||||
// Suppress warning
|
// Suppress warning
|
||||||
__INTLIFY_PROD_DEVTOOLS__: false,
|
__INTLIFY_PROD_DEVTOOLS__: false,
|
||||||
__APP_INFO__: JSON.stringify(__APP_INFO__),
|
__APP_INFO__: JSON.stringify(__APP_INFO__),
|
||||||
|
//新增以下变量,临时解决 https://github.com/vbenjs/vite-plugin-theme/issues/27
|
||||||
|
__COLOR_PLUGIN_OUTPUT_FILE_NAME__: undefined,
|
||||||
|
__PROD__: true,
|
||||||
|
__COLOR_PLUGIN_OPTIONS__: {},
|
||||||
},
|
},
|
||||||
css: {
|
css: {
|
||||||
preprocessorOptions: {
|
preprocessorOptions: {
|
||||||
|
|
Loading…
Reference in New Issue