You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 17e99ae
Browse filesBrowse the repository at this point in the historyBrowse files
Configuration options follow the formats of the underlying tools. When using APIs and helpers that Rstack CLI re-exports, prefer the `rstack/app`, `rstack/lib`, `rstack/test`, and `rstack/lint` entry points.
Defines the [Rsbuild configuration](https://rsbuild.rs/config/) for an application. It accepts a configuration object or a configuration function. The function receives the standard Rsbuild configuration parameters.
94
+
95
+
```ts title="rstack.config.ts"
96
+
import { define } from'rstack';
97
+
98
+
define.app({
99
+
html: {
100
+
title: 'My App',
101
+
},
102
+
output: {
103
+
distPath: {
104
+
root: 'dist',
105
+
},
106
+
},
107
+
});
108
+
```
109
+
110
+
### `define.lib()`\{#define-lib}
111
+
112
+
Defines the [Rslib configuration](https://rslib.rs/config/) for a library. It accepts a configuration object or a configuration function. The function receives the standard Rslib configuration parameters.
113
+
114
+
```ts title="rstack.config.ts"
115
+
import { define } from'rstack';
116
+
117
+
define.lib({
118
+
dts: true,
119
+
format: 'esm',
120
+
});
121
+
```
122
+
123
+
### `define.doc()`\{#define-doc}
124
+
125
+
Defines the [Rspress configuration](https://rspress.rs/api/config/config-basic) for a documentation site. It accepts a configuration object or an async configuration function.
126
+
127
+
```ts title="rstack.config.ts"
128
+
import { define } from'rstack';
129
+
130
+
define.doc({
131
+
root: 'docs',
132
+
title: 'My Site',
133
+
});
134
+
```
135
+
136
+
`@rspress/core` is an optional dependency of Rstack CLI. Install it in every project that uses the `rs doc` command:
Defines the [Rstest configuration](https://rstest.rs/config/). It accepts a configuration object or a configuration function.
143
+
144
+
```ts title="rstack.config.ts"
145
+
import { define } from'rstack';
146
+
147
+
define.app({
148
+
// Shared application configuration
149
+
});
150
+
151
+
define.test({
152
+
setupFiles: ['./tests/rstest.setup.ts'],
153
+
testEnvironment: 'happy-dom',
154
+
});
155
+
```
156
+
157
+
When `extends` is omitted, Rstack CLI automatically connects the test configuration to `define.app()` through the Rsbuild adapter. If no application configuration is defined, it falls back to `define.lib()` through the Rslib adapter. The application configuration takes precedence when both are defined. Set `extends` explicitly to opt out of this automatic inheritance.
158
+
159
+
If the root test configuration does not define `extends` and contains `projects`, Rstack CLI applies automatic inheritance to each inline project that omits its own `extends`. A function-based application or library configuration is resolved once and shared by those projects. String project entries are passed to Rstest unchanged; they load their external configurations independently and do not inherit the current application or library configuration.
160
+
161
+
These rules also apply to shared configurations: Rstack first merges the test settings, then uses the merged App or Lib configuration for automatic inheritance.
162
+
163
+
> For more guidance on testing, see [Testing](./testing).
164
+
165
+
### `define.lint()`\{#define-lint}
166
+
167
+
Defines the [Rslint configuration](https://rslint.rs/config/). Pass the configuration directly, or use a synchronous or asynchronous function. The function receives all exports from `rstack/lint`, so presets and plugins do not need to be imported manually.
168
+
169
+
```ts title="rstack.config.ts"
170
+
import { define } from'rstack';
171
+
172
+
define.lint(({ js, ts }) => [
173
+
js.configs.recommended,
174
+
ts.configs.recommendedTypeChecked,
175
+
]);
176
+
```
177
+
178
+
### `define.fmt()`\{#define-fmt}
179
+
180
+
Defines formatting settings for [`rs fmt`](./cli/fmt). Pass a configuration object directly, or use a synchronous or asynchronous function that returns one.
181
+
182
+
```ts title="rstack.config.ts"
183
+
import { define } from'rstack';
184
+
185
+
define.fmt({
186
+
printWidth: 100,
187
+
singleQuote: true,
188
+
});
189
+
```
190
+
191
+
For detailed usage, see [Formatting](./formatting).
192
+
193
+
### `define.staged()`\{#define-staged}
194
+
195
+
Defines the [lint-staged configuration](https://github.com/lint-staged/lint-staged#configuration) used to run tasks on staged Git files. It accepts either an object that maps glob patterns to tasks or a task-generator function. Tasks can be commands, command arrays, or functions supported by lint-staged.
`rs staged` requires a staged configuration, provided by `define.staged()` or a shared configuration, and reports an error when it is missing.
207
+
77
208
## Shared configurations
78
209
79
210
Use `define.extends()` to share build, test, lint, and formatting settings across projects. Define a shared configuration as a plain object with the `RstackConfig` type. Its fields accept the same values as the corresponding `define.*()` APIs:
Publish `setup.ts` at that location in the package, or update the path to point to its compiled output.
245
376
246
377
Local shared modules are also tracked as configuration dependencies. Editing an imported shared module reloads the App, Lib, or Doc configuration in development or watch mode.
247
-
248
-
## Configuration APIs
249
-
250
-
Configuration options follow the formats of the underlying tools. When using APIs and helpers that Rstack CLI re-exports, prefer the `rstack/app`, `rstack/lib`, `rstack/test`, and `rstack/lint` entry points.
Defines the [Rsbuild configuration](https://rsbuild.rs/config/) for an application. It accepts a configuration object or a configuration function. The function receives the standard Rsbuild configuration parameters.
265
-
266
-
```ts title="rstack.config.ts"
267
-
import { define } from'rstack';
268
-
269
-
define.app({
270
-
html: {
271
-
title: 'My App',
272
-
},
273
-
output: {
274
-
distPath: {
275
-
root: 'dist',
276
-
},
277
-
},
278
-
});
279
-
```
280
-
281
-
### `define.lib()`\{#define-lib}
282
-
283
-
Defines the [Rslib configuration](https://rslib.rs/config/) for a library. It accepts a configuration object or a configuration function. The function receives the standard Rslib configuration parameters.
284
-
285
-
```ts title="rstack.config.ts"
286
-
import { define } from'rstack';
287
-
288
-
define.lib({
289
-
dts: true,
290
-
format: 'esm',
291
-
});
292
-
```
293
-
294
-
### `define.doc()`\{#define-doc}
295
-
296
-
Defines the [Rspress configuration](https://rspress.rs/api/config/config-basic) for a documentation site. It accepts a configuration object or an async configuration function.
297
-
298
-
```ts title="rstack.config.ts"
299
-
import { define } from'rstack';
300
-
301
-
define.doc({
302
-
root: 'docs',
303
-
title: 'My Site',
304
-
});
305
-
```
306
-
307
-
`@rspress/core` is an optional dependency of Rstack CLI. Install it in every project that uses the `rs doc` command:
Defines the [Rstest configuration](https://rstest.rs/config/). It accepts a configuration object or a configuration function.
314
-
315
-
```ts title="rstack.config.ts"
316
-
import { define } from'rstack';
317
-
318
-
define.app({
319
-
// Shared application configuration
320
-
});
321
-
322
-
define.test({
323
-
setupFiles: ['./tests/rstest.setup.ts'],
324
-
testEnvironment: 'happy-dom',
325
-
});
326
-
```
327
-
328
-
When `extends` is omitted, Rstack CLI automatically connects the test configuration to `define.app()` through the Rsbuild adapter. If no application configuration is defined, it falls back to `define.lib()` through the Rslib adapter. The application configuration takes precedence when both are defined. Set `extends` explicitly to opt out of this automatic inheritance.
329
-
330
-
If the root test configuration does not define `extends` and contains `projects`, Rstack CLI applies automatic inheritance to each inline project that omits its own `extends`. A function-based application or library configuration is resolved once and shared by those projects. String project entries are passed to Rstest unchanged; they load their external configurations independently and do not inherit the current application or library configuration.
331
-
332
-
These rules also apply to shared configurations: Rstack first merges the test settings, then uses the merged App or Lib configuration for automatic inheritance.
333
-
334
-
> For more guidance on testing, see [Testing](./testing).
335
-
336
-
### `define.lint()`\{#define-lint}
337
-
338
-
Defines the [Rslint configuration](https://rslint.rs/config/). Pass the configuration directly, or use a synchronous or asynchronous function. The function receives all exports from `rstack/lint`, so presets and plugins do not need to be imported manually.
339
-
340
-
```ts title="rstack.config.ts"
341
-
import { define } from'rstack';
342
-
343
-
define.lint(({ js, ts }) => [
344
-
js.configs.recommended,
345
-
ts.configs.recommendedTypeChecked,
346
-
]);
347
-
```
348
-
349
-
### `define.fmt()`\{#define-fmt}
350
-
351
-
Defines formatting settings for [`rs fmt`](./cli/fmt). Pass a configuration object directly, or use a synchronous or asynchronous function that returns one.
352
-
353
-
```ts title="rstack.config.ts"
354
-
import { define } from'rstack';
355
-
356
-
define.fmt({
357
-
printWidth: 100,
358
-
singleQuote: true,
359
-
});
360
-
```
361
-
362
-
For detailed usage, see [Formatting](./formatting).
363
-
364
-
### `define.staged()`\{#define-staged}
365
-
366
-
Defines the [lint-staged configuration](https://github.com/lint-staged/lint-staged#configuration) used to run tasks on staged Git files. It accepts either an object that maps glob patterns to tasks or a task-generator function. Tasks can be commands, command arrays, or functions supported by lint-staged.
0 commit comments