2021-11-29 09:19:15 +08:00
|
|
|
import { defineConfig, loadEnv } from 'vite';
|
2022-08-10 21:31:59 +08:00
|
|
|
import { createViteProxy, getRootPath, getSrcPath, setupVitePlugins, viteDefine } from './build';
|
2022-07-28 13:19:50 +08:00
|
|
|
import { getServiceEnvConfig } from './.env-config';
|
2021-05-28 00:32:34 +08:00
|
|
|
|
2022-04-01 14:47:57 +08:00
|
|
|
export default defineConfig(configEnv => {
|
2022-07-28 13:19:50 +08:00
|
|
|
const viteEnv = loadEnv(configEnv.mode, process.cwd()) as unknown as ImportMetaEnv;
|
2022-04-27 19:01:54 +08:00
|
|
|
|
2022-06-16 01:17:31 +08:00
|
|
|
const rootPath = getRootPath();
|
|
|
|
const srcPath = getSrcPath();
|
2022-03-12 19:32:15 +08:00
|
|
|
|
2022-07-16 00:13:19 +08:00
|
|
|
const isOpenProxy = viteEnv.VITE_HTTP_PROXY === 'Y';
|
2022-07-28 13:19:50 +08:00
|
|
|
const envConfig = getServiceEnvConfig(viteEnv);
|
2022-04-27 22:27:46 +08:00
|
|
|
|
2021-11-29 09:19:15 +08:00
|
|
|
return {
|
2022-03-05 01:55:21 +08:00
|
|
|
base: viteEnv.VITE_BASE_URL,
|
2021-11-29 09:19:15 +08:00
|
|
|
resolve: {
|
|
|
|
alias: {
|
2022-04-27 19:01:54 +08:00
|
|
|
'~': rootPath,
|
2023-09-06 00:14:35 +08:00
|
|
|
'@': srcPath
|
2022-04-01 14:47:57 +08:00
|
|
|
}
|
2021-11-29 09:19:15 +08:00
|
|
|
},
|
2022-03-13 16:47:19 +08:00
|
|
|
define: viteDefine,
|
2022-06-16 01:17:31 +08:00
|
|
|
plugins: setupVitePlugins(viteEnv),
|
2021-11-29 09:19:15 +08:00
|
|
|
css: {
|
|
|
|
preprocessorOptions: {
|
|
|
|
scss: {
|
2022-04-01 14:47:57 +08:00
|
|
|
additionalData: `@use "./src/styles/scss/global.scss" as *;`
|
|
|
|
}
|
|
|
|
}
|
2021-11-29 09:19:15 +08:00
|
|
|
},
|
|
|
|
server: {
|
2021-11-29 10:57:29 +08:00
|
|
|
host: '0.0.0.0',
|
2022-12-07 01:11:45 +08:00
|
|
|
port: 3200,
|
2022-03-12 16:21:40 +08:00
|
|
|
open: true,
|
2022-04-27 22:27:46 +08:00
|
|
|
proxy: createViteProxy(isOpenProxy, envConfig)
|
2022-01-04 13:53:07 +08:00
|
|
|
},
|
2022-08-03 22:25:04 +08:00
|
|
|
optimizeDeps: {
|
|
|
|
include: [
|
|
|
|
'@antv/data-set',
|
|
|
|
'@antv/g2',
|
|
|
|
'@better-scroll/core',
|
|
|
|
'echarts',
|
|
|
|
'swiper',
|
|
|
|
'swiper/vue',
|
|
|
|
'vditor',
|
|
|
|
'wangeditor',
|
|
|
|
'xgplayer'
|
|
|
|
]
|
|
|
|
},
|
2022-01-04 13:53:07 +08:00
|
|
|
build: {
|
2022-06-19 15:34:18 +08:00
|
|
|
reportCompressedSize: false,
|
2022-06-06 12:09:15 +08:00
|
|
|
sourcemap: false,
|
2022-05-31 23:02:24 +08:00
|
|
|
commonjsOptions: {
|
|
|
|
ignoreTryCatch: false
|
|
|
|
}
|
2022-04-01 14:47:57 +08:00
|
|
|
}
|
2021-11-29 09:19:15 +08:00
|
|
|
};
|
2021-05-28 02:22:49 +08:00
|
|
|
});
|