ruoyi-plus-soybean/vite.config.ts

47 lines
1.2 KiB
TypeScript
Raw Normal View History

2023-12-14 21:45:29 +08:00
import process from 'node:process';
import { URL, fileURLToPath } from 'node:url';
import { defineConfig, loadEnv } from 'vite';
2023-11-17 08:45:00 +08:00
import { setupVitePlugins } from './build/plugins';
import { createViteProxy } from './build/config';
export default defineConfig(configEnv => {
2023-11-17 08:45:00 +08:00
const viteEnv = loadEnv(configEnv.mode, process.cwd()) as unknown as Env.ImportMeta;
2022-04-27 22:27:46 +08:00
return {
base: viteEnv.VITE_BASE_URL,
resolve: {
alias: {
2023-11-17 08:45:00 +08:00
'~': fileURLToPath(new URL('./', import.meta.url)),
'@': fileURLToPath(new URL('./src', import.meta.url))
}
},
css: {
preprocessorOptions: {
scss: {
additionalData: `@use "./src/styles/scss/global.scss" as *;`
}
}
},
2023-11-17 08:45:00 +08:00
plugins: setupVitePlugins(viteEnv),
define: {
BUILD_TIME: JSON.stringify(new Date().toISOString())
},
server: {
2021-11-29 10:57:29 +08:00
host: '0.0.0.0',
2023-11-17 08:45:00 +08:00
port: 9527,
open: true,
2023-11-17 08:45:00 +08:00
proxy: createViteProxy(viteEnv)
},
2023-11-17 08:45:00 +08:00
preview: {
port: 9725
},
build: {
2022-06-19 15:34:18 +08:00
reportCompressedSize: false,
2023-11-17 08:45:00 +08:00
sourcemap: viteEnv.VITE_SOURCE_MAP === 'Y',
commonjsOptions: {
ignoreTryCatch: false
}
}
};
});