-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathvite.config.ssr.ts
More file actions
33 lines (32 loc) · 1.06 KB
/
vite.config.ssr.ts
File metadata and controls
33 lines (32 loc) · 1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import { defineConfig } from 'vite';
import preact from '@preact/preset-vite';
import mdx from '@mdx-js/rollup';
import { unifiedMdxPreprocessor } from './src/plugins/unified-mdx-plugin';
import { getMdxConfig } from './src/config/mdx';
// Minimal Vite config for the SSR build.
// Only includes plugins needed for MDX compilation — no sitemap, prerender,
// analytics, or other build-time plugins that target the client output.
export default defineConfig({
plugins: [
unifiedMdxPreprocessor(),
preact(),
mdx(getMdxConfig(false)),
],
resolve: {
dedupe: ['preact', 'preact/compat', 'preact/hooks', 'preact/jsx-runtime', 'preact/compat/jsx-runtime'],
alias: {
react: 'preact/compat',
'react-dom': 'preact/compat',
}
},
build: {
ssr: 'src/entry-server.tsx',
outDir: 'dist-ssr',
},
ssr: {
// Bundle all dependencies so preact/compat aliases resolve correctly.
// Without this, externalized imports like @headlessui/react would
// import 'react' directly, bypassing the preact alias.
noExternal: true,
},
});