forked from rstackjs/rstack-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrsbuildConfig.ts
More file actions
41 lines (35 loc) · 1.03 KB
/
Copy pathrsbuildConfig.ts
File metadata and controls
41 lines (35 loc) · 1.03 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
import type { ConfigParams, RsbuildConfigDefinition, WatchFiles } from '@rsbuild/core';
import { loadRstackConfig, type Configs } from './config.ts';
const resolveRsbuildConfig = async (configs: Configs, params: ConfigParams) => {
const appConfig = configs.app;
if (!appConfig) {
return {};
}
if (typeof appConfig === 'function') {
return appConfig(params);
}
return appConfig;
};
const loadRsbuildConfig: RsbuildConfigDefinition = async (params) => {
const { configs, filePath, dependencies } = await loadRstackConfig();
const config = await resolveRsbuildConfig(configs, params);
if (!filePath) {
return config;
}
const watchFiles = config.dev?.watchFiles;
const watchConfig: WatchFiles = {
paths: [filePath, ...dependencies],
type: 'reload-server',
};
return {
...config,
dev: {
...config.dev,
watchFiles: [
...(watchFiles ? (Array.isArray(watchFiles) ? watchFiles : [watchFiles]) : []),
watchConfig,
],
},
};
};
export default loadRsbuildConfig;