88 lines
2.4 KiB
TypeScript
88 lines
2.4 KiB
TypeScript
/* eslint-disable */
|
|
import path from 'path';
|
|
import vue from '@vitejs/plugin-vue';
|
|
import vueJsx from '@vitejs/plugin-vue-jsx';
|
|
import { ConfigEnv, loadEnv, UserConfig } from 'vite';
|
|
import svgLoader from 'vite-svg-loader';
|
|
import AutoImport from 'unplugin-auto-import/vite';
|
|
import Components from 'unplugin-vue-components/vite';
|
|
import { TDesignResolver } from 'unplugin-vue-components/resolvers';
|
|
import vueDevTools from 'vite-plugin-vue-devtools';
|
|
|
|
const CWD = process.cwd();
|
|
|
|
// https://vitejs.dev/config/
|
|
export default ({ mode }: ConfigEnv): UserConfig => {
|
|
// const { VITE_BASE_URL, VITE_API_URL_PREFIX } = loadEnv(mode, CWD);
|
|
|
|
const { VITE_BASE_URL, VITE_API_URL_PREFIX, VITE_API_URL_MK } = loadEnv(mode, CWD);
|
|
return {
|
|
base: VITE_BASE_URL,
|
|
resolve: {
|
|
alias: {
|
|
'@': path.resolve(__dirname, './src'),
|
|
},
|
|
},
|
|
|
|
css: {
|
|
preprocessorOptions: {
|
|
less: {
|
|
modifyVars: {
|
|
hack: `true; @import (reference) "${path.resolve('src/style/variables.less')}";`,
|
|
},
|
|
math: 'strict',
|
|
javascriptEnabled: true,
|
|
},
|
|
},
|
|
},
|
|
|
|
plugins: [
|
|
vue(),
|
|
vueJsx(),
|
|
svgLoader(),
|
|
AutoImport({
|
|
imports: ['vue', 'pinia', 'vue-router'],
|
|
dts: 'types/auto-imports.d.ts',
|
|
resolvers: [
|
|
TDesignResolver({
|
|
library: 'vue-next',
|
|
}),
|
|
],
|
|
}),
|
|
Components({
|
|
dts: 'types/components.d.ts',
|
|
resolvers: [
|
|
TDesignResolver({
|
|
library: 'vue-next',
|
|
}),
|
|
],
|
|
}),
|
|
// vue3 devtools
|
|
vueDevTools(),
|
|
],
|
|
|
|
server: {
|
|
host: '127.0.0.1', // 服务器地址
|
|
port: 3800, // 服务器端口号
|
|
open: false, // 是否自动打开浏览器
|
|
hmr: true, // 启用热更新
|
|
proxy: {
|
|
'/api': {
|
|
// target: 'http://192.168.203.25:8091/', // 本地测试
|
|
target: 'http://172.16.20.1:8091', // 线上测试
|
|
// target: 'http://localhost:12344', // wky测试
|
|
changeOrigin: true,
|
|
rewrite: (path) => path.replace(/^\/api/, ''),
|
|
},
|
|
'/y4_sys': {
|
|
// target: 'http://192.168.203.25:8091/', // 本地测试
|
|
target: 'http://172.16.20.1:8091', // 线上测试
|
|
// target: 'http://localhost:12344', // wky测试
|
|
changeOrigin: true,
|
|
rewrite: (path) => path.replace(/^\/api/, ''),
|
|
},
|
|
},
|
|
},
|
|
};
|
|
};
|