diff --git a/vite.config.ts b/vite.config.ts index c5c75d1..6c41b61 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -2,19 +2,25 @@ import { vitePlugin as remix } from '@remix-run/dev'; import { vanillaExtractPlugin } from '@vanilla-extract/vite-plugin'; import { defineConfig } from 'vite'; import tsconfigPaths from 'vite-tsconfig-paths'; -import { remixCloudflareDevProxyVitePlugin } from './server'; -export default defineConfig({ - plugins: [ - remixCloudflareDevProxyVitePlugin(), - remix({ - future: { - v3_fetcherPersist: true, - v3_relativeSplatPath: true, - v3_throwAbortReason: true, - }, - }), - tsconfigPaths(), - vanillaExtractPlugin(), - ], +export default defineConfig(async ({ command }) => { + const { remixCloudflareDevProxyVitePlugin } = + command === 'serve' + ? await import('./server') + : { remixCloudflareDevProxyVitePlugin: undefined }; + + return { + plugins: [ + remixCloudflareDevProxyVitePlugin?.(), + remix({ + future: { + v3_fetcherPersist: true, + v3_relativeSplatPath: true, + v3_throwAbortReason: true, + }, + }), + tsconfigPaths(), + vanillaExtractPlugin(), + ].filter((item) => item !== undefined), + }; });