vite.config.ts 620 Bytes
import { defineConfig } from "vite";
import uni from "@dcloudio/vite-plugin-uni";

// https://vitejs.dev/config/
export default defineConfig({
  base: "/app/",
  plugins: [
    uni(),
    {
      name: "redirect-root-to-app",
      configureServer(server) {
        server.middlewares.use((req, res, next) => {
          const url = (req.url || "/").split("?")[0];
          if (url === "/" || url === "/index.html") {
            res.writeHead(302, { Location: "/app/" });
            res.end();
            return;
          }
          next();
        });
      },
    },
  ],
  server: {
    open: "/app/",
  },
});