Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: should writeToDisk correctly when environment writeToDisk configuration same #4269

Merged
merged 3 commits into from
Dec 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading