Skip to content

Commit

Permalink
feat: Added a writeToDisk predefined option to Rsbuild dev config (#234)
Browse files Browse the repository at this point in the history
  • Loading branch information
patricklafrance authored Feb 8, 2025
1 parent 45ee89b commit ad94f27
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/sharp-weeks-watch.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@workleap/rsbuild-configs": minor
---

Added a new `writeToDisk` predefined option for the dev config.
15 changes: 15 additions & 0 deletions docs/rsbuild/configure-dev.md
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,21 @@ export default defineDevConfig({
});
```

### `writeToDisk`

- **Type**: `true`
- **Default**: `undefined`

Whether or not to [write the build output](https://rsbuild.dev/config/dev/write-to-disk) from the development server to the disk.

```ts !#4 rsbuild.dev.ts
import { defineDevConfig } from "@workleap/rsbuild-configs";

export default defineDevConfig({
writeToDisk: true
});
```

### `react`

- **Type**: `false` or `(defaultOptions: PluginReactOptions) => PluginReactOptions`
Expand Down
5 changes: 4 additions & 1 deletion packages/rsbuild-configs/src/dev.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export interface DefineDevConfigOptions {
fastRefresh?: boolean;
sourceMap?: false | SourceMap;
overlay?: false;
writeToDisk?: true;
react?: false | DefineDevDefineReactPluginConfigFunction;
svgr? : false | DefineDevSvgrPluginConfigFunction;
environmentVariables?: Record<string, unknown>;
Expand Down Expand Up @@ -62,6 +63,7 @@ export function defineDevConfig(options: DefineDevConfigOptions = {}) {
css: true
},
overlay,
writeToDisk,
react = defaultDefineReactPluginConfig,
svgr = defineSvgrPluginConfig,
// Using an empty object literal as the default value to ensure
Expand All @@ -79,7 +81,8 @@ export function defineDevConfig(options: DefineDevConfigOptions = {}) {
hmr: hmr || fastRefresh,
client: (overlay === false || fastRefresh) ? {
overlay: false
} : undefined
} : undefined,
writeToDisk
},
server: {
https: isBoolean(https) ? undefined : https,
Expand Down
8 changes: 8 additions & 0 deletions packages/rsbuild-configs/tests/dev.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,14 @@ test("when overlay is false, react plugin fast refresh overlay is disabled", ()
expect(isOverlayDisabled).toBeTruthy();
});

test("when writeToDisk is true, the dev.writeToDisk option is true", () => {
const result = defineDevConfig({
writeToDisk: true
});

expect(result.dev?.writeToDisk).toBeTruthy();
});

test("when react is false, the react plugin is not included", () => {
const result = defineDevConfig({
react: false
Expand Down

0 comments on commit ad94f27

Please sign in to comment.