ruoyi-plus-soybean/vite.config.ts

52 lines
1.2 KiB
TypeScript
Raw Normal View History

import { fileURLToPath } from 'url';
import { defineConfig, loadEnv } from 'vite';
2022-01-08 20:49:21 +08:00
import { setupVitePlugins, define } from './build';
2022-03-12 19:32:15 +08:00
import { getEnvConfig } from './.env-config';
export default defineConfig((configEnv) => {
const viteEnv = loadEnv(configEnv.mode, `.env.${configEnv.mode}`) as ImportMetaEnv;
const srcPath = fileURLToPath(new URL('./src', import.meta.url));
const rootPath = fileURLToPath(new URL('./', import.meta.url));
2022-03-12 19:32:15 +08:00
const { http } = getEnvConfig(viteEnv);
return {
base: viteEnv.VITE_BASE_URL,
resolve: {
alias: {
'@': srcPath,
'~': rootPath,
},
},
2022-01-08 20:49:21 +08:00
define,
plugins: setupVitePlugins(configEnv, srcPath, viteEnv),
css: {
preprocessorOptions: {
scss: {
additionalData: `@use "./src/styles/scss/global.scss" as *;`,
},
},
},
server: {
2021-12-24 11:00:10 +08:00
fs: {
strict: false,
2021-12-24 11:00:10 +08:00
},
2021-11-29 10:57:29 +08:00
host: '0.0.0.0',
port: 3200,
open: true,
2022-03-12 19:32:15 +08:00
proxy: {
[http.proxy]: {
target: http.url,
changeOrigin: true,
rewrite: (path) => path.replace(new RegExp(`^${http.proxy}`), ''),
},
},
},
build: {
brotliSize: false,
sourcemap: false,
},
};
});