vite.config.ts 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. import react from "@vitejs/plugin-react";
  2. import { codeInspectorPlugin } from "code-inspector-plugin";
  3. import { resolve } from "path";
  4. import { defineConfig } from "vite";
  5. let devProxyServer = "http://localhost:8081";
  6. if (process.env.DEV_PROXY_SERVER && process.env.DEV_PROXY_SERVER.length > 0) {
  7. console.log("Use devProxyServer from environment: ", process.env.DEV_PROXY_SERVER);
  8. devProxyServer = process.env.DEV_PROXY_SERVER;
  9. }
  10. // https://vitejs.dev/config/
  11. export default defineConfig({
  12. plugins: [
  13. react(),
  14. codeInspectorPlugin({
  15. bundler: "vite",
  16. }),
  17. ],
  18. server: {
  19. host: "0.0.0.0",
  20. port: 3001,
  21. proxy: {
  22. "^/api": {
  23. target: devProxyServer,
  24. xfwd: true,
  25. },
  26. "^/memos.api.v1": {
  27. target: devProxyServer,
  28. xfwd: true,
  29. },
  30. "^/file": {
  31. target: devProxyServer,
  32. xfwd: true,
  33. },
  34. },
  35. },
  36. resolve: {
  37. alias: {
  38. "@/": `${resolve(__dirname, "src")}/`,
  39. },
  40. },
  41. build: {
  42. rollupOptions: {
  43. output: {
  44. entryFileNames: "app.[hash].js",
  45. chunkFileNames: "assets/chunk-vendors.[hash].js",
  46. assetFileNames: "assets/[name].[hash][extname]",
  47. },
  48. },
  49. },
  50. });