ruoyi-plus-soybean/vite.config.ts

59 lines
1.3 KiB
TypeScript
Raw Normal View History

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