You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

29 lines
800 B

4 weeks ago
1 month ago
4 weeks ago
  1. import { defineConfig,loadEnv } from "vite";
  2. import { wrapperEnv } from "./build/utils";
  3. import vue from "@vitejs/plugin-vue";
  4. import { resolve } from "path"; //
  5. export default defineConfig(({ command, mode }) => {
  6. const root = process.cwd();
  7. const env = loadEnv(mode, root);
  8. const viteEnv = wrapperEnv(env);
  9. const { VITE_PUBLIC_PATH, VITE_OUTPUT_DIR } = viteEnv;
  10. return {
  11. base: VITE_PUBLIC_PATH,
  12. plugins: [vue()], //
  13. server: {
  14. host: "192.168.1.102",
  15. port: 5173,
  16. // 错误1:server 块内不能嵌套 plugins 配置(已删除)
  17. proxy: {
  18. "/api": {
  19. target: "http://192.168.99.223:3000",
  20. changeOrigin: true,
  21. rewrite: (path) => path.replace(/^\/api/, ""),
  22. },
  23. },
  24. },
  25. resolve: {
  26. },
  27. };
  28. });