|
4 | 4 | updateContextByNormalizedConfig, |
5 | 5 | updateEnvironmentContext, |
6 | 6 | } from '../createContext'; |
7 | | -import { camelCase, color, pick } from '../helpers'; |
| 7 | +import { camelCase, color, getAbsolutePath, pick } from '../helpers'; |
8 | 8 | import { isDebug, logger } from '../logger'; |
9 | 9 | import { mergeRsbuildConfig } from '../mergeConfig'; |
10 | 10 | import { initPlugins } from '../pluginManager'; |
@@ -160,6 +160,15 @@ const validateRsbuildConfig = (config: NormalizedConfig) => { |
160 | 160 | } |
161 | 161 | }; |
162 | 162 |
|
| 163 | +/** |
| 164 | + * Initialize the Rsbuild config |
| 165 | + * 1. Initialize the Rsbuild plugins |
| 166 | + * 2. Run all the `modifyRsbuildConfig` hooks |
| 167 | + * 3. Normalize the Rsbuild config, merge with the default config |
| 168 | + * 4. Initialize the configs for each environment |
| 169 | + * 5. Run all the `modifyEnvironmentConfig` hooks |
| 170 | + * 6. Validate the final Rsbuild config |
| 171 | + */ |
163 | 172 | export async function initRsbuildConfig({ |
164 | 173 | context, |
165 | 174 | pluginManager, |
@@ -207,14 +216,26 @@ export async function initRsbuildConfig({ |
207 | 216 | name, |
208 | 217 | ); |
209 | 218 |
|
210 | | - environments[name] = { |
| 219 | + const normalizedEnvironmentConfig = { |
211 | 220 | ...environmentConfig, |
212 | 221 | dev: { |
213 | 222 | ...environmentConfig.dev, |
214 | 223 | ...rsbuildSharedDev, |
215 | 224 | }, |
216 | 225 | server, |
217 | 226 | }; |
| 227 | + |
| 228 | + const { tsconfigPath } = normalizedEnvironmentConfig.source; |
| 229 | + |
| 230 | + // Ensure the `tsconfigPath` is an absolute path |
| 231 | + if (tsconfigPath) { |
| 232 | + normalizedEnvironmentConfig.source.tsconfigPath = getAbsolutePath( |
| 233 | + context.rootPath, |
| 234 | + tsconfigPath, |
| 235 | + ); |
| 236 | + } |
| 237 | + |
| 238 | + environments[name] = normalizedEnvironmentConfig; |
218 | 239 | } |
219 | 240 |
|
220 | 241 | context.normalizedConfig = { |
|
0 commit comments