Skip to content

Commit 65dc112

Browse files
authored
feat: optimize UI for assets report page (#3902)
1 parent acbf73e commit 65dc112

File tree

2 files changed

+49
-7
lines changed

2 files changed

+49
-7
lines changed

e2e/cases/server/viewing-served-files/index.test.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ rspackOnlyTest(
1818
const titles = await page.$$eval('h1', (nodes) =>
1919
nodes.map((n) => n.textContent),
2020
);
21-
expect(titles.includes('Assets Report:')).toBe(true);
21+
expect(titles.includes('Assets Report')).toBe(true);
2222

2323
// check all href are valid
2424
const hrefList = await page.$$eval('ul li a', (nodes) =>
@@ -61,7 +61,7 @@ rspackOnlyTest(
6161
const titles = await page.$$eval('h1', (nodes) =>
6262
nodes.map((n) => n.textContent),
6363
);
64-
expect(titles.includes('Assets Report:')).toBe(true);
64+
expect(titles.includes('Assets Report')).toBe(true);
6565

6666
// check all href are valid
6767
const hrefList = await page.$$eval('ul li a', (nodes) =>
@@ -118,9 +118,9 @@ rspackOnlyTest(
118118
const subTitles = await page.$$eval('h2', (nodes) =>
119119
nodes.map((n) => n.textContent),
120120
);
121-
expect(titles.includes('Assets Report:')).toBe(true);
122-
expect(subTitles.includes('Compilation: test1')).toBe(true);
123-
expect(subTitles.includes('Compilation: test2')).toBe(true);
121+
expect(titles.includes('Assets Report')).toBe(true);
122+
expect(subTitles.includes('Environment: test1')).toBe(true);
123+
expect(subTitles.includes('Environment: test2')).toBe(true);
124124

125125
// check all href are valid
126126
const hrefList = await page.$$eval('ul li a', (nodes) =>

packages/core/src/server/middlewares.ts

Lines changed: 44 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -260,12 +260,54 @@ export const viewingServedFilesMiddleware: (params: {
260260
if (pathname === '/rsbuild-dev-server') {
261261
res.writeHead(200, { 'Content-Type': 'text/html; charset=utf-8' });
262262
res.write(
263-
'<!DOCTYPE html><html><head><meta charset="utf-8"/></head><body><h1>Assets Report:</h1>',
263+
`<!DOCTYPE html>
264+
<html>
265+
<head>
266+
<meta charset="utf-8"/>
267+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
268+
<style>
269+
body {
270+
margin: 0;
271+
color: #f6f7f9;
272+
padding: 32px 40px;
273+
line-height: 1.8;
274+
min-height: 100vh;
275+
background-image: linear-gradient(#020917, #101725);
276+
font-family: ui-sans-serif,system-ui,sans-serif;
277+
}
278+
h1, h2 {
279+
font-weight: 500;
280+
}
281+
h1 {
282+
margin: 0;
283+
font-size: 36px;
284+
}
285+
h2 {
286+
font-size: 20px;
287+
margin: 24px 0 16px;
288+
}
289+
ul {
290+
margin: 0;
291+
padding-left: 16px;
292+
}
293+
a {
294+
color: #58c4dc;
295+
text-decoration: none;
296+
}
297+
a:hover {
298+
text-decoration: underline;
299+
}
300+
</style>
301+
</head>
302+
<body>
303+
<h1>Assets Report</h1>
304+
</body>
305+
</html>`,
264306
);
265307
try {
266308
for (const key in environments) {
267309
const list = [];
268-
res.write(`<h2>Compilation: ${key}</h2>`);
310+
res.write(`<h2>Environment: ${key}</h2>`);
269311
const environment = environments[key];
270312
const stats = await environment.getStats();
271313
const statsForPrint = stats.toJson();

0 commit comments

Comments
 (0)