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';
|
2022-02-25 23:19:12 +08:00
|
|
|
import { defineConfig, loadEnv, ConfigEnv } from 'vite';
|
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);
|
|
|
|
};
|
|
|
|
|
|
|
|
const alias: Record<string, string> = {
|
2021-08-20 18:58:52 +08:00
|
|
|
'/@': pathResolve('./src/'),
|
2021-04-01 11:13:38 +08:00
|
|
|
'vue-i18n': 'vue-i18n/dist/vue-i18n.cjs.js',
|
|
|
|
};
|
|
|
|
|
2022-02-25 23:19:12 +08:00
|
|
|
const viteConfig = defineConfig((mode: ConfigEnv) => {
|
|
|
|
const env = loadEnv(mode.mode, process.cwd());
|
2022-02-21 23:52:59 +08:00
|
|
|
return {
|
|
|
|
plugins: [vue()],
|
|
|
|
root: process.cwd(),
|
|
|
|
resolve: { alias },
|
2022-02-25 23:19:12 +08:00
|
|
|
base: mode.command === 'serve' ? './' : env.VITE_PUBLIC_PATH,
|
2022-04-18 19:14:38 +08:00
|
|
|
hmr: true,
|
2022-02-21 23:52:59 +08:00
|
|
|
optimizeDeps: {
|
|
|
|
include: ['element-plus/lib/locale/lang/zh-cn', 'element-plus/lib/locale/lang/en', 'element-plus/lib/locale/lang/zh-tw'],
|
|
|
|
},
|
|
|
|
server: {
|
|
|
|
host: '0.0.0.0',
|
2022-02-25 23:19:12 +08:00
|
|
|
port: env.VITE_PORT as unknown as number,
|
|
|
|
open: env.VITE_OPEN,
|
2022-02-21 23:52:59 +08:00
|
|
|
proxy: {
|
|
|
|
'/gitee': {
|
|
|
|
target: 'https://gitee.com',
|
|
|
|
ws: true,
|
|
|
|
changeOrigin: true,
|
|
|
|
rewrite: (path) => path.replace(/^\/gitee/, ''),
|
|
|
|
},
|
2021-03-15 12:44:58 +08:00
|
|
|
},
|
|
|
|
},
|
2022-02-21 23:52:59 +08:00
|
|
|
build: {
|
|
|
|
outDir: 'dist',
|
|
|
|
sourcemap: false,
|
|
|
|
chunkSizeWarningLimit: 1500,
|
|
|
|
rollupOptions: {
|
|
|
|
output: {
|
|
|
|
entryFileNames: `assets/[name].${new Date().getTime()}.js`,
|
|
|
|
chunkFileNames: `assets/[name].${new Date().getTime()}.js`,
|
|
|
|
assetFileNames: `assets/[name].${new Date().getTime()}.[ext]`,
|
|
|
|
compact: true,
|
|
|
|
manualChunks: {
|
2022-04-19 21:15:06 +08:00
|
|
|
vue: ['vue', 'vue-router', 'pinia'],
|
2022-02-21 23:52:59 +08:00
|
|
|
echarts: ['echarts'],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2021-12-21 21:32:26 +08:00
|
|
|
},
|
2022-02-21 23:52:59 +08:00
|
|
|
css: {
|
|
|
|
postcss: {
|
|
|
|
plugins: [
|
|
|
|
{
|
|
|
|
postcssPlugin: 'internal:charset-removal',
|
|
|
|
AtRule: {
|
|
|
|
charset: (atRule) => {
|
|
|
|
if (atRule.name === 'charset') {
|
|
|
|
atRule.remove();
|
|
|
|
}
|
|
|
|
},
|
2021-12-22 21:37:33 +08:00
|
|
|
},
|
|
|
|
},
|
2022-02-21 23:52:59 +08:00
|
|
|
],
|
|
|
|
},
|
2021-12-22 21:37:33 +08:00
|
|
|
},
|
2022-02-21 23:52:59 +08:00
|
|
|
define: {
|
|
|
|
__VUE_I18N_LEGACY_API__: JSON.stringify(false),
|
|
|
|
__VUE_I18N_FULL_INSTALL__: JSON.stringify(false),
|
|
|
|
__INTLIFY_PROD_DEVTOOLS__: JSON.stringify(false),
|
|
|
|
},
|
|
|
|
};
|
|
|
|
});
|
2022-02-25 23:19:12 +08:00
|
|
|
|
|
|
|
export default viteConfig;
|