2021-03-15 12:44:58 +08:00
|
|
|
import vue from '@vitejs/plugin-vue';
|
2021-04-01 11:13:38 +08:00
|
|
|
import { resolve } from 'path';
|
2021-03-15 12:44:58 +08:00
|
|
|
import type { UserConfig } from 'vite';
|
2021-06-19 17:49:42 +08:00
|
|
|
import { loadEnv } from './src/utils/viteBuild';
|
2020-12-21 00:14:57 +08:00
|
|
|
|
2021-04-01 11:13:38 +08:00
|
|
|
const pathResolve = (dir: string): any => {
|
|
|
|
return resolve(__dirname, '.', dir);
|
|
|
|
};
|
|
|
|
|
2021-03-15 12:44:58 +08:00
|
|
|
const { VITE_PORT, VITE_OPEN, VITE_PUBLIC_PATH } = loadEnv();
|
2020-12-21 00:14:57 +08:00
|
|
|
|
2021-04-01 11:13:38 +08:00
|
|
|
const alias: Record<string, string> = {
|
|
|
|
'/@': pathResolve('/src/'),
|
|
|
|
'vue-i18n': 'vue-i18n/dist/vue-i18n.cjs.js',
|
|
|
|
};
|
|
|
|
|
2020-12-09 08:55:57 +08:00
|
|
|
const viteConfig: UserConfig = {
|
2021-03-15 12:44:58 +08:00
|
|
|
plugins: [vue()],
|
|
|
|
root: process.cwd(),
|
2021-04-01 11:13:38 +08:00
|
|
|
resolve: { alias },
|
2021-03-15 12:44:58 +08:00
|
|
|
base: process.env.NODE_ENV === 'production' ? VITE_PUBLIC_PATH : './',
|
|
|
|
optimizeDeps: {
|
2021-04-01 11:13:38 +08:00
|
|
|
include: ['element-plus/lib/locale/lang/zh-cn', 'element-plus/lib/locale/lang/en', 'element-plus/lib/locale/lang/zh-tw'],
|
2021-03-15 12:44:58 +08:00
|
|
|
},
|
|
|
|
server: {
|
2021-05-12 11:32:31 +08:00
|
|
|
host: '0.0.0.0',
|
2021-03-15 12:44:58 +08:00
|
|
|
port: VITE_PORT,
|
|
|
|
open: VITE_OPEN,
|
|
|
|
proxy: {
|
|
|
|
'/gitee': {
|
|
|
|
target: 'https://gitee.com',
|
|
|
|
ws: true,
|
|
|
|
changeOrigin: true,
|
|
|
|
rewrite: (path) => path.replace(/^\/gitee/, ''),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
build: {
|
|
|
|
outDir: 'dist',
|
|
|
|
minify: 'esbuild',
|
|
|
|
sourcemap: false,
|
|
|
|
},
|
2021-04-09 18:14:50 +08:00
|
|
|
define: {
|
|
|
|
__VUE_I18N_LEGACY_API__: JSON.stringify(false),
|
|
|
|
__VUE_I18N_FULL_INSTALL__: JSON.stringify(false),
|
|
|
|
__INTLIFY_PROD_DEVTOOLS__: JSON.stringify(false),
|
|
|
|
},
|
2021-03-15 12:44:58 +08:00
|
|
|
};
|
2020-12-09 08:55:57 +08:00
|
|
|
|
2021-03-15 12:44:58 +08:00
|
|
|
export default viteConfig;
|