-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* fix(#5817): remove duplicate CSS in dev * chore: add changeset Co-authored-by: Nate Moore <[email protected]>
- Loading branch information
1 parent
4987d6f
commit 7325df4
Showing
11 changed files
with
107 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'astro': patch | ||
--- | ||
|
||
Fix duplicate CSS in dev mode when `vite.css.devSourcemap` is provided |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { expect } from '@playwright/test'; | ||
import { getColor, isWindows, testFactory } from './test-utils.js'; | ||
|
||
const test = testFactory({ | ||
root: './fixtures/css/', | ||
}); | ||
|
||
let devServer; | ||
|
||
test.beforeAll(async ({ astro }) => { | ||
devServer = await astro.startDevServer(); | ||
}); | ||
|
||
test.afterAll(async () => { | ||
await devServer.stop(); | ||
}); | ||
|
||
test.describe('CSS Sourcemap HMR', () => { | ||
test.skip(isWindows, 'TODO: fix css hmr in windows'); | ||
|
||
test('removes Astro-injected CSS once Vite-injected CSS loads', async ({ page, astro }) => { | ||
const html = await astro.fetch('/').then(res => res.text()); | ||
|
||
// style[data-astro-dev-id] should exist in initial SSR'd markup | ||
expect(html).toMatch('data-astro-dev-id'); | ||
|
||
await page.goto(astro.resolveUrl('/')); | ||
|
||
// Ensure JS has initialized | ||
await page.waitForTimeout(500); | ||
|
||
// style[data-astro-dev-id] should NOT exist once JS runs | ||
expect(await page.locator('style[data-astro-dev-id]').count()).toEqual(0); | ||
|
||
// style[data-vite-dev-id] should exist now | ||
expect(await page.locator('style[data-vite-dev-id]').count()).toBeGreaterThan(0); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
export default { | ||
vite: { | ||
css: { | ||
devSourcemap: true, | ||
} | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"name": "@e2e/css-sourcemaps", | ||
"version": "0.0.0", | ||
"private": true, | ||
"dependencies": { | ||
"astro": "workspace:*" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/// <reference types="astro/client" /> |
9 changes: 9 additions & 0 deletions
9
packages/astro/e2e/fixtures/css-sourcemaps/src/pages/index.astro
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<h1>hello world</h1> | ||
|
||
<style> | ||
@import "../styles/main.css"; | ||
|
||
h1 { | ||
color: var(--h1-color); | ||
} | ||
</style> |
3 changes: 3 additions & 0 deletions
3
packages/astro/e2e/fixtures/css-sourcemaps/src/styles/main.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
:root { | ||
--h1-color: red; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.