+
CSS Collection Test - Sass Mixin
+
+ This page tests that Sass mixins imported in a parent file are available
+ to subsequent imports during dev mode SSR.
+
+
+
+
+ Sass Mixin Applied - Should be centered with purple background
+
+
+
+ )
+}
diff --git a/e2e/react-start/css-modules/src/styles/app.scss b/e2e/react-start/css-modules/src/styles/app.scss
new file mode 100644
index 0000000000..2c2fde6cb2
--- /dev/null
+++ b/e2e/react-start/css-modules/src/styles/app.scss
@@ -0,0 +1,4 @@
+// Import the mixin, which should make them available to future imports
+@import './center-mixin.scss';
+
+@import './mixin-consumer.scss';
diff --git a/e2e/react-start/css-modules/src/styles/center-mixin.scss b/e2e/react-start/css-modules/src/styles/center-mixin.scss
new file mode 100644
index 0000000000..7eeb174b6e
--- /dev/null
+++ b/e2e/react-start/css-modules/src/styles/center-mixin.scss
@@ -0,0 +1,5 @@
+@mixin center-mixin {
+ display: flex;
+ justify-content: center;
+ align-items: center;
+}
diff --git a/e2e/react-start/css-modules/src/styles/mixin-consumer.scss b/e2e/react-start/css-modules/src/styles/mixin-consumer.scss
new file mode 100644
index 0000000000..52715c90b0
--- /dev/null
+++ b/e2e/react-start/css-modules/src/styles/mixin-consumer.scss
@@ -0,0 +1,10 @@
+.mixin-container {
+ // Use the center mixin, which is included in app.scss
+ // This works for the client build, but not for the dev server styles.css build
+ @include center-mixin;
+ background-color: #a855f7; /* purple-500 */
+ padding: 24px;
+ border-radius: 12px;
+ color: white;
+ min-height: 100px;
+}
diff --git a/e2e/react-start/css-modules/tests/css.spec.ts b/e2e/react-start/css-modules/tests/css.spec.ts
index bdfd2308a4..ba876cc2ae 100644
--- a/e2e/react-start/css-modules/tests/css.spec.ts
+++ b/e2e/react-start/css-modules/tests/css.spec.ts
@@ -113,6 +113,44 @@ test.describe('CSS styles in SSR (dev mode)', () => {
const className = await element.getAttribute('class')
expect(className).toBe('global-container')
})
+
+ test('Sass mixin styles are applied on initial page load', async ({
+ page,
+ baseURL,
+ }) => {
+ await page.goto(buildUrl(baseURL!, '/sass-mixin'))
+
+ const element = page.getByTestId('mixin-styled')
+ await expect(element).toBeVisible()
+
+ // Verify the mixin is applied (display: flex from center-mixin)
+ const display = await element.evaluate(
+ (el) => getComputedStyle(el).display,
+ )
+ expect(display).toBe('flex')
+
+ const justifyContent = await element.evaluate(
+ (el) => getComputedStyle(el).justifyContent,
+ )
+ expect(justifyContent).toBe('center')
+
+ const alignItems = await element.evaluate(
+ (el) => getComputedStyle(el).alignItems,
+ )
+ expect(alignItems).toBe('center')
+
+ // Verify other styles from mixin-consumer.scss
+ // #a855f7 (purple-500) in RGB is rgb(168, 85, 247)
+ const backgroundColor = await element.evaluate(
+ (el) => getComputedStyle(el).backgroundColor,
+ )
+ expect(backgroundColor).toBe('rgb(168, 85, 247)')
+
+ const padding = await element.evaluate(
+ (el) => getComputedStyle(el).padding,
+ )
+ expect(padding).toBe('24px')
+ })
})
test('styles persist after hydration', async ({ page, baseURL }) => {
diff --git a/e2e/react-start/css-modules/vite.config.ts b/e2e/react-start/css-modules/vite.config.ts
index 6027af4bfa..9dacdf984a 100644
--- a/e2e/react-start/css-modules/vite.config.ts
+++ b/e2e/react-start/css-modules/vite.config.ts
@@ -22,9 +22,11 @@ export default defineConfig(async () => {
tsConfigPaths({
projects: ['./tsconfig.json'],
}),
+ // Nitro is placed BEFORE tanstackStart to test that our CSS middleware
+ // works regardless of plugin order (nitro has a catch-all middleware)
+ ...nitroPlugin,
tanstackStart(),
viteReact(),
- ...nitroPlugin,
],
}
})
diff --git a/e2e/solid-start/css-modules/package.json b/e2e/solid-start/css-modules/package.json
index 4acefb88ae..934c4ffa62 100644
--- a/e2e/solid-start/css-modules/package.json
+++ b/e2e/solid-start/css-modules/package.json
@@ -22,6 +22,7 @@
"@playwright/test": "^1.50.1",
"@tanstack/router-e2e-utils": "workspace:*",
"@types/node": "^22.10.2",
+ "sass": "^1.97.2",
"srvx": "^0.10.0",
"typescript": "^5.7.2",
"vite": "^7.1.7",
diff --git a/e2e/solid-start/css-modules/src/routes/__root.tsx b/e2e/solid-start/css-modules/src/routes/__root.tsx
index 304d76fb33..9ee18b1a5a 100644
--- a/e2e/solid-start/css-modules/src/routes/__root.tsx
+++ b/e2e/solid-start/css-modules/src/routes/__root.tsx
@@ -50,6 +50,13 @@ function RootComponent() {
>
CSS Modules
+