57 lines
1.5 KiB
TypeScript
57 lines
1.5 KiB
TypeScript
/// <reference types="vitest" />
|
|
|
|
// import { cloudflare } from "@cloudflare/vite-plugin";
|
|
import tailwindcss from "@tailwindcss/vite";
|
|
import react from "@vitejs/plugin-react";
|
|
import { dirname, resolve } from "path";
|
|
import { visualizer } from "rollup-plugin-visualizer";
|
|
import { fileURLToPath } from "url";
|
|
import { defineConfig, ViteDevServer, type PluginOption } from "vite";
|
|
import tsconfigPaths from "vite-tsconfig-paths";
|
|
|
|
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
|
|
// https://vitejs.dev/config/
|
|
export default defineConfig({
|
|
plugins: [
|
|
react(),
|
|
visualizer() as PluginOption,
|
|
tailwindcss(),
|
|
tsconfigPaths(),
|
|
{
|
|
name: "configure-server",
|
|
configureServer(server: ViteDevServer) {
|
|
return () => {
|
|
server.middlewares.use(async (req, _res, next) => {
|
|
for (const appName of Object.keys(
|
|
server.config.build.rollupOptions.input as Record<string, string>
|
|
)) {
|
|
if (req?.originalUrl?.startsWith(`/${appName}`)) {
|
|
req.url = `/${appName}/index.html`;
|
|
break;
|
|
}
|
|
}
|
|
next();
|
|
});
|
|
};
|
|
},
|
|
},
|
|
// cloudflare(),
|
|
],
|
|
server: {
|
|
cors: false,
|
|
},
|
|
test: {
|
|
globals: true,
|
|
environment: "jsdom",
|
|
setupFiles: "./src/setupTests.ts",
|
|
},
|
|
build: {
|
|
rollupOptions: {
|
|
input: {
|
|
main: resolve(__dirname, "index.html"),
|
|
external: resolve(__dirname, "external/index.html"),
|
|
},
|
|
},
|
|
},
|
|
});
|