Skip to content
vite.config.js 662 B
Newer Older
Grant's avatar
Grant committed
import { defineConfig } from "vite";
import react from "@vitejs/plugin-react";
import * as child from "child_process";

const commitHash = child
  .execSync("git rev-parse --short HEAD")
  .toString()
  .trim();
Grant's avatar
Grant committed

export default defineConfig({
  root: "src",
  envDir: "..",
  build: {
Grant's avatar
Grant committed
    outDir: "../dist",
Grant's avatar
Grant committed
    emptyOutDir: true,
Grant's avatar
Grant committed
    sourcemap: true,
Grant's avatar
Grant committed
  },
  plugins: [
    react({
      include: "**/*.{jsx,tsx}",
    }),
  ],
  define: {
    __COMMIT_HASH__: JSON.stringify(commitHash),
  },
  server: {
    proxy: {
      "/api": "http://localhost:3000",
      "/socket.io": {
        target: "ws://localhost:3000",
        ws: true,
      },
    },
  },
Grant's avatar
Grant committed
});