-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrsbuild.config.ts
More file actions
71 lines (69 loc) · 1.65 KB
/
rsbuild.config.ts
File metadata and controls
71 lines (69 loc) · 1.65 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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
import path from 'node:path';
import { defineConfig } from '@rsbuild/core';
import { pluginReact } from '@rsbuild/plugin-react';
import { Layers, pluginRSC } from 'rsbuild-plugin-rsc';
import type NodeHandler from './src/entry.rsc';
const reactRouterInternalClientPath = path.join(
import.meta.dirname,
'./src/react-router-internal-client.ts',
);
export default defineConfig({
source: {
alias: {
'react-router/internal/react-server-client':
reactRouterInternalClientPath,
},
},
tools: {
bundlerChain(chain) {
chain.resolve.alias.set(
'react-router/internal/react-server-client',
reactRouterInternalClientPath,
);
},
rspack(config) {
config.resolve.alias = {
...(config.resolve.alias ?? {}),
'react-router/internal/react-server-client':
reactRouterInternalClientPath,
};
},
},
plugins: [
pluginReact(),
pluginRSC({
layers: {
ssr: [path.join(import.meta.dirname, './src/entry.ssr.tsx')],
},
}),
],
environments: {
server: {
source: {
entry: {
index: {
import: './src/entry.rsc.tsx',
layer: Layers.rsc,
},
},
},
},
client: {
source: {
entry: {
index: './src/entry.browser.tsx',
},
},
},
},
server: {
setup: ({ server }) => {
server.middlewares.use(async (req, res, next) => {
const indexModule = await server.environments.server.loadBundle<{
default: NodeHandler;
}>('index');
await indexModule.default.nodeHandler(req, res, next);
});
},
},
});