-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/vite.config.mjs b/vite.config.mjs
index 09134a0..1726a3c 100644
--- a/vite.config.mjs
+++ b/vite.config.mjs
@@ -1,26 +1,27 @@
-import {
- defineConfig,
- loadEnv
-} from 'vite';
-import { resolve } from 'path'
+import { defineConfig, loadEnv } from 'vite';
+import { resolve } from 'path';
import createVitePlugins from './vite/plugins';
// https://vitejs.dev/config/
-export default ({
- mode,
- command
-}) => {
- const env = loadEnv(mode, process.cwd())
- const {
- VITE_APP_ENV,
- VITE_APP_BASE
- } = env
+export default ({ mode, command }) => {
+ const env = loadEnv(mode, process.cwd());
+ const { VITE_APP_ENV, VITE_APP_BASE } = env;
// 判断是打生产环境包
- const isProd = VITE_APP_ENV === 'production'
+ const isProd = VITE_APP_ENV === 'production';
+
+ const assetFileNames = assetInfo => {
+ const fileName = assetInfo.names?.[0] || assetInfo.name || '';
+ return fileName.endsWith('.mjs') ? 'assets/[name]-[hash].js' : 'assets/[name]-[hash][extname]';
+ };
// 根据是否生产环境,动态设置压缩配置
const buildConfig = {
target: 'esnext',
minify: isProd ? 'terser' : 'esbuild', // 根据环境选择压缩工具
+ rollupOptions: {
+ output: {
+ assetFileNames,
+ },
+ },
};
// 如果是生产环境,添加Terser的配置
@@ -31,17 +32,13 @@ export default ({
drop_debugger: true, // 删除 debugger
},
format: {
- comments: false // 删除所有注释
- }
+ comments: false, // 删除所有注释
+ },
+ };
+ buildConfig.rollupOptions.output.manualChunks = {
+ 'element-plus': ['element-plus'],
+ '@smallwei/avue': ['@smallwei/avue'],
};
- buildConfig.rollupOptions = {
- output: {
- manualChunks: {
- 'element-plus': ['element-plus'],
- '@smallwei/avue': ['@smallwei/avue']
- },
- }
- }
}
return defineConfig({
base: VITE_APP_BASE,
@@ -50,26 +47,26 @@ export default ({
__VUE_I18N_LEGACY_API__: true,
__INTLIFY_PROD_DEVTOOLS__: false,
},
- // server: {
- // port: 2888,
- // proxy: {
- // '/api': {
- // target: 'http://localhost',
- // //target: 'https://saber3.bladex.cn/api',
- // changeOrigin: true,
- // rewrite: path => path.replace(/^\/api/, ''),
- // },
- // },
- // },
server: {
- port: 2889,
+ port: 2888,
proxy: {
'/api': {
- target: 'http://172.16.203.228:8000',
+ target: 'http://localhost',
+ //target: 'https://saber3.bladex.cn/api',
changeOrigin: true,
+ rewrite: path => path.replace(/^\/api/, ''),
},
},
},
+ // server: {
+ // port: 2889,
+ // proxy: {
+ // '/api': {
+ // target: 'http://172.16.203.228:8000',
+ // changeOrigin: true,
+ // },
+ // },
+ // },
resolve: {
alias: {
'~': resolve(__dirname, './'),