55 lines
1.2 KiB
TypeScript
55 lines
1.2 KiB
TypeScript
|
|
import { defineConfig, loadEnv } from 'vite';
|
||
|
|
import vue from '@vitejs/plugin-vue';
|
||
|
|
import vueJsx from '@vitejs/plugin-vue-jsx';
|
||
|
|
import { resolve } from 'path';
|
||
|
|
|
||
|
|
// https://vitejs.dev/config/
|
||
|
|
export default defineConfig(({ mode }) => {
|
||
|
|
const env = loadEnv(mode, process.cwd(), '');
|
||
|
|
|
||
|
|
return {
|
||
|
|
base: env.VITE_BASE_URL || '/',
|
||
|
|
plugins: [vue(), vueJsx()],
|
||
|
|
resolve: {
|
||
|
|
alias: {
|
||
|
|
'@': resolve(__dirname, 'src'),
|
||
|
|
},
|
||
|
|
},
|
||
|
|
css: {
|
||
|
|
modules: {
|
||
|
|
localsConvention: 'camelCaseOnly',
|
||
|
|
},
|
||
|
|
preprocessorOptions: {
|
||
|
|
less: {
|
||
|
|
javascriptEnabled: true,
|
||
|
|
},
|
||
|
|
},
|
||
|
|
},
|
||
|
|
server: {
|
||
|
|
host: '0.0.0.0',
|
||
|
|
port: Number(env.VITE_PORT) || 5173,
|
||
|
|
open: true,
|
||
|
|
proxy: {
|
||
|
|
'/api': {
|
||
|
|
target: env.VITE_API_BASE_URL || 'http://localhost:3000',
|
||
|
|
changeOrigin: true,
|
||
|
|
rewrite: (path) => path.replace(/^\/api/, ''),
|
||
|
|
},
|
||
|
|
},
|
||
|
|
},
|
||
|
|
build: {
|
||
|
|
outDir: 'dist',
|
||
|
|
sourcemap: mode !== 'production',
|
||
|
|
chunkSizeWarningLimit: 1500,
|
||
|
|
rollupOptions: {
|
||
|
|
output: {
|
||
|
|
manualChunks: {
|
||
|
|
vue: ['vue', 'vue-router'],
|
||
|
|
antd: ['ant-design-vue'],
|
||
|
|
},
|
||
|
|
},
|
||
|
|
},
|
||
|
|
},
|
||
|
|
};
|
||
|
|
});
|