import { defineConfig } from 'vite' import vue from '@vitejs/plugin-vue' import path from 'path' // https://vitejs.dev/config/ export default defineConfig({ base: './', plugins: [vue()], resolve: { alias: { '@': path.resolve(__dirname, 'src'), '@styles': path.resolve(__dirname, 'src/styles') } }, css: { preprocessorOptions: { scss: { additionalData: '' } } }, server: { port: 12345, strictPort: false, host: true, cors: true, proxy: { '^/api': { target: 'https://shop.wenxingshuju.com', changeOrigin: true, secure: false, rewrite: (path) => path, configure: (proxy, options) => { // 添加必要的响应头 proxy.on('proxyRes', (proxyRes, req, res) => { proxyRes.headers['Access-Control-Allow-Origin'] = '*' proxyRes.headers['Access-Control-Allow-Methods'] = 'GET,POST,PUT,DELETE,OPTIONS' proxyRes.headers['Access-Control-Allow-Headers'] = 'Content-Type,Authorization' }) } } } }, logLevel: 'info', clearScreen: false, build: { sourcemap: true } })