From e809e1b6d7419ca06a50416183b165cbca65f5cf Mon Sep 17 00:00:00 2001 From: neverland Date: Tue, 5 Nov 2024 19:03:45 +0800 Subject: [PATCH 1/2] feat: optimize UI for assets report page --- packages/core/src/server/middlewares.ts | 46 +++++++++++++++++++++++-- 1 file changed, 44 insertions(+), 2 deletions(-) diff --git a/packages/core/src/server/middlewares.ts b/packages/core/src/server/middlewares.ts index ad41db1d5..d34fca995 100644 --- a/packages/core/src/server/middlewares.ts +++ b/packages/core/src/server/middlewares.ts @@ -260,12 +260,54 @@ export const viewingServedFilesMiddleware: (params: { if (pathname === '/rsbuild-dev-server') { res.writeHead(200, { 'Content-Type': 'text/html; charset=utf-8' }); res.write( - '

Assets Report:

', + ` + + + + + + + +

Assets Report

+ +`, ); try { for (const key in environments) { const list = []; - res.write(`

Compilation: ${key}

`); + res.write(`

Environment: ${key}

`); const environment = environments[key]; const stats = await environment.getStats(); const statsForPrint = stats.toJson(); From dfb1592da0f5ebe3aae7b4eda9cba5ef8ba8ad74 Mon Sep 17 00:00:00 2001 From: neverland Date: Tue, 5 Nov 2024 19:10:19 +0800 Subject: [PATCH 2/2] test --- e2e/cases/server/viewing-served-files/index.test.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/e2e/cases/server/viewing-served-files/index.test.ts b/e2e/cases/server/viewing-served-files/index.test.ts index 87e39f72b..bb3979175 100644 --- a/e2e/cases/server/viewing-served-files/index.test.ts +++ b/e2e/cases/server/viewing-served-files/index.test.ts @@ -18,7 +18,7 @@ rspackOnlyTest( const titles = await page.$$eval('h1', (nodes) => nodes.map((n) => n.textContent), ); - expect(titles.includes('Assets Report:')).toBe(true); + expect(titles.includes('Assets Report')).toBe(true); // check all href are valid const hrefList = await page.$$eval('ul li a', (nodes) => @@ -61,7 +61,7 @@ rspackOnlyTest( const titles = await page.$$eval('h1', (nodes) => nodes.map((n) => n.textContent), ); - expect(titles.includes('Assets Report:')).toBe(true); + expect(titles.includes('Assets Report')).toBe(true); // check all href are valid const hrefList = await page.$$eval('ul li a', (nodes) => @@ -118,9 +118,9 @@ rspackOnlyTest( const subTitles = await page.$$eval('h2', (nodes) => nodes.map((n) => n.textContent), ); - expect(titles.includes('Assets Report:')).toBe(true); - expect(subTitles.includes('Compilation: test1')).toBe(true); - expect(subTitles.includes('Compilation: test2')).toBe(true); + expect(titles.includes('Assets Report')).toBe(true); + expect(subTitles.includes('Environment: test1')).toBe(true); + expect(subTitles.includes('Environment: test2')).toBe(true); // check all href are valid const hrefList = await page.$$eval('ul li a', (nodes) =>