Skip to content
Source
Sign inSign up
TanStack/router
Open History to see the last commit

rsbuild.config.ts

47 lines1.4 KB

1import { defineConfig } from '@rsbuild/core'
2import { pluginReact } from '@rsbuild/plugin-react'
3import { pluginSass } from '@rsbuild/plugin-sass'
4import { tanstackStart } from '@tanstack/react-start/plugin/rsbuild'
5​
6export default defineConfig({
7 plugins: [pluginReact(), pluginSass(), tanstackStart()],
8 output: {
9 distPath: {
10 root: process.env.E2E_DIST_DIR ?? 'dist-rsbuild-ssr',
11 },
12 },
13 tools: {
14 rspack(config, { environment }) {
15 if (environment.name === 'ssr') {
16 config.output ??= {}
17 config.output.filename = 'server.js'
18 }
19 if (environment.name !== 'client') {
20 return
21 }
22 config.optimization ??= {}
23 // Extract the shared component and its helper into their own chunks so
24 // a route depends on a shared chunk that depends on another shared chunk.
25 config.optimization.splitChunks = {
26 cacheGroups: {
27 sharedHeader: {
28 test: /[\\/]src[\\/]components[\\/]/,
29 chunks: 'async',
30 minChunks: 2,
31 minSize: 0,
32 enforce: true,
33 name: 'shared-header',
34 },
35 sharedFormat: {
36 test: /[\\/]src[\\/]utils[\\/]/,
37 chunks: 'async',
38 minChunks: 2,
39 minSize: 0,
40 enforce: true,
41 name: 'shared-format',
42 },
43 },
44 }
45 },
46 },
47})