-
Notifications
You must be signed in to change notification settings - Fork 153
/
rsbuild.config.ts
125 lines (120 loc) · 2.83 KB
/
rsbuild.config.ts
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
import path from "path"
import nodeExternals from "webpack-node-externals"
import LoadablePlugin from "@loadable/webpack-plugin"
import { defineConfig } from "@rsbuild/core"
import { pluginReact } from "@rsbuild/plugin-react"
import { pluginAssetsRetry } from "@rsbuild/plugin-assets-retry"
import { pluginNodePolyfill } from "@rsbuild/plugin-node-polyfill"
import { EarlyHintsPlugin } from "./rspack/plugins/EarlyHintsPlugin"
import { loadEnvs } from "@artsy/multienv"
loadEnvs(".env.shared", ".env")
export default defineConfig({
environments: {
client: {
plugins: [pluginAssetsRetry()],
source: {
entry: {
index: "./src/client.tsx",
},
},
output: {
target: "web",
manifest: true,
externals: {
async_hooks: "async_hooks", // Required because getAsyncStorage isn't using async import()
},
},
tools: {
htmlPlugin: false,
rspack: {
plugins: [
new EarlyHintsPlugin(),
new LoadablePlugin({
filename: "loadable-stats.json",
}),
],
},
},
},
server: {
output: {
target: "node",
distPath: {
root: "dist/server",
},
},
source: {
entry: {
index: "./src/server",
},
},
tools: {
rspack: {
externals: [nodeExternals()],
node: {
__dirname: true,
},
},
swc: {
module: {
type: "commonjs",
},
},
},
},
},
/**
* Shared config across environments
*/
dev: {
progressBar: true,
writeToDisk: true,
},
performance: {
// TODO: Uncomment and play around with different bundle split strategies,
// along with stats below:
// chunkSplit: {
// strategy: "split-by-size",
// minSize: 30000,
// maxSize: 50000,
// },
...(process.env.GENERATE_STATS_FILE
? {
bundleAnalyze: {
generateStatsFile: true,
},
}
: {}),
},
plugins: [pluginReact(), pluginNodePolyfill()],
server: {
port: Number(process.env.PORT) || 3000,
},
tools: {
swc: {
jsc: {
experimental: {
plugins: [
["@swc/plugin-loadable-components", {}],
[
"@swc/plugin-styled-components",
{
ssr: true,
displayName: true,
},
],
[
"@swc/plugin-relay",
{
// Must be fully-resolved absolute path
rootDir: path.resolve(process.cwd(), "src"),
artifactDirectory: "__generated__",
language: "typescript",
},
],
],
},
},
},
},
})