// Import { defineConfig } from 'vite'import vue from '@vitejs/plugin-vue'/* * https://vitejs.dev/config/ * export default defineConfig({ * plugins: [vue()] */// })import path from "path";/* Par ({ command, mode }) */export default ({ command }) => { if (command === 'serve') { return { // Serve 独有配置 'base': './', 'mode': 'development', // 默认值 'publicDir': 'public', // 路径别名 'alias': { // '@': path.resolve(__dirname, "./src"), // map '@' to './src' // '#': pathResolve("./components") }, 'plugins': [ // vue({ 'template': { 'compilerOptions': { // ... } } }) ], 'css': { }, 'server': { // 端口 'port': '', // 时若端口已被占用则会直接退出,而不是尝试下一个可用端口。 'strictPort': true /* * Https:"" * Open:"" 打开浏览器 地址 * Proxy:{} //代理规则 */ } } } return { // Build 独有配置 'base': '/admin/', 'mode': 'production', // 默认值 'publicDir': 'public', 'plugins': [ // vue({ 'template': { 'compilerOptions': { // ... } } }) ], 'css': { }, 'server': { // 指定服务器主机名 'host': '', // 代理规则 'proxy': { // 字符串简写写法 '/foo': 'http://localhost:5000/foo', // 选项写法 '/api': { 'target': 'http://jsonplaceholder.typicode.com', 'changeOrigin': true, 'rewrite': path => path.replace( /^\/api/, '' ) }, // 正则表达式写法 '^/fallback/.*': { 'target': 'http://jsonplaceholder.typicode.com', 'changeOrigin': true, 'rewrite': path => path.replace( /^\/fallback/, '' ) } } } }}