yunshangxie-admin/vite.config.js

60 lines
1.2 KiB
JavaScript
Raw Permalink Normal View History

2024-04-18 13:44:38 +08:00
import { loadEnv } from 'vite';
import { viteMockServe } from 'vite-plugin-mock';
import { createVuePlugin } from 'vite-plugin-vue2';
import { createSvgPlugin } from 'vite-plugin-vue2-svg';
import path from 'path';
const CWD = process.cwd();
export default ({ mode }) => {
const { VITE_BASE_URL } = loadEnv(mode, CWD);
return {
base: VITE_BASE_URL,
resolve: {
alias: {
'~': path.resolve(__dirname, './'),
'@': path.resolve(__dirname, './src'),
},
},
css: {
preprocessorOptions: {
less: {
modifyVars: {},
},
},
},
plugins: [
createVuePlugin({
jsx: true,
}),
viteMockServe({
mockPath: 'mock',
localEnabled: true,
}),
createSvgPlugin(),
],
build: {
cssCodeSplit: false,
},
server: {
proxy: {
'/api': {
// 用于开发环境下的转发请求
// 更多请参考https://vitejs.dev/config/#server-proxy
target: 'http://192.168.3.130/',
pathRewrite: {
'^/api': ''
},
changeOrigin: true,
},
},
},
};
};