diff --git a/vite.config.ts b/vite.config.ts index 5855c96..9bda7cd 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -15,20 +15,22 @@ export default defineConfig(({ isSsrBuild }) => ({ } : undefined, }, - resolve: { - alias: isSsrBuild - ? [] - : [ - { - find: "~/database/context", - replacement: path.resolve( - __dirname, - "database/context.browser-stub.ts" - ), - }, - ], - }, - plugins: [tailwindcss(), reactRouter(), tsconfigPaths()], + plugins: [ + { + name: "database-context-alias", + enforce: "pre" as const, + resolveId(id, _importer, options) { + if (id === "~/database/context") { + return options?.ssr + ? path.resolve(__dirname, "database/context.ts") + : path.resolve(__dirname, "database/context.browser-stub.ts"); + } + }, + }, + tailwindcss(), + reactRouter(), + tsconfigPaths(), + ], server: { allowedHosts: true, },