Skip to content

Commit

Permalink
fix: should writeToDisk correctly when environment writeToDisk config…
Browse files Browse the repository at this point in the history
…uration same (#4269)
  • Loading branch information
9aoy authored Dec 25, 2024
1 parent de5c335 commit d2730f9
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 1 deletion.
44 changes: 44 additions & 0 deletions e2e/cases/server/write-to-disk-environments/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,47 @@ test('multiple environments writeToDisk should work correctly', async ({

await rsbuild.close();
});

test('should writeToDisk correctly when environment writeToDisk configuration same', async ({
page,
}) => {
const rsbuild = await dev({
cwd,
page,
rsbuildConfig: {
dev: {
writeToDisk: false,
},
environments: {
web: {
output: {
distPath: {
root: 'dist-same',
},
},
dev: {
writeToDisk: true,
},
},
web1: {
output: {
distPath: {
root: 'dist-same-1',
},
},
dev: {
writeToDisk: true,
},
},
},
},
});

const test = page.locator('#test');
await expect(test).toHaveText('Hello Rsbuild!');

expect(fs.existsSync(join(cwd, 'dist-same/index.html'))).toBeTruthy();
expect(fs.existsSync(join(cwd, 'dist-same-1/index.html'))).toBeTruthy();

await rsbuild.close();
});
5 changes: 4 additions & 1 deletion packages/core/src/server/compilerDevMiddleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,10 @@ const formatDevConfig = (
(env) => env.config.dev.writeToDisk,
);
if (new Set(writeToDiskValues).size === 1) {
return config;
return {
...config,
writeToDisk: writeToDiskValues[0],
};
}

return {
Expand Down

0 comments on commit d2730f9

Please sign in to comment.