2023-01-16 18:54:21 +08:00
|
|
|
import vue from '@vitejs/plugin-vue';
|
2021-08-26 11:25:15 +08:00
|
|
|
import vueJsx from '@vitejs/plugin-vue-jsx';
|
2021-10-18 17:04:47 +08:00
|
|
|
import path from 'path';
|
2023-04-05 15:40:41 +08:00
|
|
|
import { ConfigEnv, loadEnv, UserConfig } from 'vite';
|
|
|
|
import { viteMockServe } from 'vite-plugin-mock';
|
|
|
|
import svgLoader from 'vite-svg-loader';
|
2021-08-26 11:25:15 +08:00
|
|
|
|
2022-03-21 13:50:58 +08:00
|
|
|
const CWD = process.cwd();
|
|
|
|
|
2021-08-26 11:25:15 +08:00
|
|
|
// https://vitejs.dev/config/
|
2022-03-21 13:50:58 +08:00
|
|
|
export default ({ mode }: ConfigEnv): UserConfig => {
|
2023-03-15 15:34:36 +08:00
|
|
|
const { VITE_BASE_URL, VITE_API_URL_PREFIX } = loadEnv(mode, CWD);
|
2022-03-21 13:50:58 +08:00
|
|
|
return {
|
|
|
|
base: VITE_BASE_URL,
|
|
|
|
resolve: {
|
|
|
|
alias: {
|
|
|
|
'@': path.resolve(__dirname, './src'),
|
|
|
|
},
|
2021-08-26 11:25:15 +08:00
|
|
|
},
|
2021-10-18 17:04:47 +08:00
|
|
|
|
2022-10-01 11:28:42 +08:00
|
|
|
css: {
|
|
|
|
preprocessorOptions: {
|
|
|
|
less: {
|
|
|
|
modifyVars: {
|
|
|
|
hack: `true; @import (reference) "${path.resolve('src/style/variables.less')}";`,
|
|
|
|
},
|
|
|
|
math: 'strict',
|
|
|
|
javascriptEnabled: true,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
2022-03-21 13:50:58 +08:00
|
|
|
plugins: [
|
2023-01-16 18:54:21 +08:00
|
|
|
vue(),
|
2022-03-21 13:50:58 +08:00
|
|
|
vueJsx(),
|
|
|
|
viteMockServe({
|
|
|
|
mockPath: 'mock',
|
|
|
|
localEnabled: true,
|
|
|
|
}),
|
|
|
|
svgLoader(),
|
|
|
|
],
|
2021-10-18 17:04:47 +08:00
|
|
|
|
2022-03-21 13:50:58 +08:00
|
|
|
server: {
|
|
|
|
port: 3002,
|
|
|
|
host: '0.0.0.0',
|
|
|
|
proxy: {
|
2023-03-15 15:34:36 +08:00
|
|
|
[VITE_API_URL_PREFIX]: 'http://127.0.0.1:3000/',
|
2022-03-21 13:50:58 +08:00
|
|
|
},
|
2021-12-12 15:46:02 +08:00
|
|
|
},
|
2022-03-21 13:50:58 +08:00
|
|
|
};
|
|
|
|
};
|