diff --git a/packages/playground/backend-integration/__tests__/backend-integration.spec.ts b/packages/playground/backend-integration/__tests__/backend-integration.spec.ts index fdd92dd82a32d6..3e189972f4baed 100644 --- a/packages/playground/backend-integration/__tests__/backend-integration.spec.ts +++ b/packages/playground/backend-integration/__tests__/backend-integration.spec.ts @@ -32,15 +32,28 @@ if (isBuild) { expect(htmlEntry.assets.length).toEqual(1) }) } else { - test('preserve the base in CSS HMR', async () => { - await untilUpdated(() => getColor('body'), 'black') // sanity check - editFile('frontend/entrypoints/global.css', (code) => - code.replace('black', 'red') - ) - await untilUpdated(() => getColor('body'), 'red') // successful HMR + describe('CSS HMR', () => { + test('preserve the base in CSS HMR', async () => { + await untilUpdated(() => getColor('body'), 'black') // sanity check + editFile('frontend/entrypoints/global.css', (code) => + code.replace('black', 'red') + ) + await untilUpdated(() => getColor('body'), 'red') // successful HMR - // Verify that the base (/dev/) was added during the css-update - const link = await page.$('link[rel="stylesheet"]') - expect(await link.getAttribute('href')).toContain('/dev/global.css?t=') + // Verify that the base (/dev/) was added during the css-update + const link = await page.$('link[rel="stylesheet"]') + expect(await link.getAttribute('href')).toContain('/dev/global.css?t=') + }) + + test('CSS dependencies are tracked for HMR', async () => { + const el = await page.$('h1') + browserLogs.length = 0 + + editFile('frontend/entrypoints/main.ts', (code) => + code.replace('text-black', 'text-[rgb(204,0,0)]') + ) + await untilUpdated(() => getColor(el), 'rgb(204, 0, 0)') + expect(browserLogs).toContain('[vite] css hot updated: /global.css') + }) }) } diff --git a/packages/playground/backend-integration/frontend/entrypoints/global.css b/packages/playground/backend-integration/frontend/entrypoints/global.css index 915692c7a5c061..9a15d3b9794599 100644 --- a/packages/playground/backend-integration/frontend/entrypoints/global.css +++ b/packages/playground/backend-integration/frontend/entrypoints/global.css @@ -1,4 +1,5 @@ @import '~/styles/background.css'; +@import '~/styles/tailwind.css'; @import '../../references.css'; html, diff --git a/packages/playground/backend-integration/frontend/entrypoints/index.html b/packages/playground/backend-integration/frontend/entrypoints/index.html index 3b8dedb4ac3096..ef9e046e9ea177 100644 --- a/packages/playground/backend-integration/frontend/entrypoints/index.html +++ b/packages/playground/backend-integration/frontend/entrypoints/index.html @@ -2,7 +2,7 @@ -

Backend Integration

+

Backend Integration

This test configures the root to simulate a Laravel/Rails setup. @@ -27,6 +27,7 @@

CSS Asset References

+