赞
踩
新建vite.config.js
import type { UserConfig, ConfigEnv } from "vite"; import vue from '@vitejs/plugin-vue'; import { resolve } from 'path'; import { loadEnv } from 'vite'; // import basicSsl from '@vitejs/plugin-basic-ssl' 如果是https 需要引入 function pathResolve(dir: string) { return resolve(process.cwd(), '.', dir); } export default ({command, mode}: ConfigEnv): UserConfig => { const root = process.cwd() const env = loadEnv(mode, root) return { base: env.VITE_PUBLIC_PATH, root, server: { host: '0.0.0.0', port: 3000, open: true, strictPort: false, https: fasle, // https 设置为true proxy: { '/api': { target: 'your host', // http://192.168.1.1:20/ changeOrigin: true, rewrite: (path) => path.replace(/^\/api/, '') // 路径重写 } } }, resolve: { alias: [ { find: /\/@\//, replacement: pathResolve('src') + '/' } ] }, build: { watch: {}, manifest: true }, plugins: [ vue(), // basicSsl(), // https 打开此配置 ] } }
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。