import { defineConfig } from 'vite' import vue from '@vitejs/plugin-vue' // import {nodePolyfills} from 'vite-plugin-node-polyfills' // https://vitejs.dev/config/ export default defineConfig({ plugins: [ vue(), // nodePolyfills({ // globals: { // Buffer: false // } // }), ], base: './', // build: { // // 打包输出目录 // outDir: 'dist', // // 打包文件名 // assetsDir: 'static', // sourcemap: false, // 禁用源映射 // // 静态资源引用路径 // assetsPublicPath: '/', // // 是否开启压缩 // minify: 'terser', // // 分离代码 // // splitChunks: {}, // // 环境变量 // env: { // BASE_URL: process.env.VITE_API_BASE_URL // }, // rollupOptions: { // plugins: [nodePolyfills()], // }, // commonjsOptions: { // transformMixedEsModules: true, // } // }, define: { global: {}, 'process.env': {} }, server: { port: 5173, // 设置服务启动端口号 open: false, // 设置服务启动时是否自动打开浏览器 cors: true, // 允许跨域 // host: 'localhost', // hmr:true, // 设置代理,根据我们项目实际情况配置 proxy: { '/api': { target: process.env.VITE_BASE_API, // 将 /api 开头的请求代理到该地址 changeOrigin: true, secure: false, rewrite: (path) => path.replace('/api/', '/') } } } })