Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions e2e/react-start/css-modules/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
"@types/react-dom": "^19.0.3",
"@vitejs/plugin-react": "^4.3.4",
"nitro": "npm:nitro-nightly@latest",
"sass": "^1.97.2",
"srvx": "^0.10.0",
"typescript": "^5.7.2",
"vite": "^7.1.7",
Expand Down
7 changes: 7 additions & 0 deletions e2e/react-start/css-modules/src/routes/__root.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,13 @@ function RootComponent() {
>
CSS Modules
</Link>
<Link
to="/sass-mixin"
style={{ color: '#0284c7', textDecoration: 'none' }}
data-testid="nav-sass-mixin"
>
Sass Mixin
</Link>
</nav>

<main style={{ padding: '20px' }}>
Expand Down
24 changes: 24 additions & 0 deletions e2e/react-start/css-modules/src/routes/sass-mixin.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { createFileRoute } from '@tanstack/react-router'
import '~/styles/app.scss'

export const Route = createFileRoute('/sass-mixin')({
component: SassMixin,
})

function SassMixin() {
return (
<div>
<h1>CSS Collection Test - Sass Mixin</h1>
<p>
This page tests that Sass mixins imported in a parent file are available
to subsequent imports during dev mode SSR.
</p>

<div className="mixin-container" data-testid="mixin-styled">
<span data-testid="mixin-content">
Sass Mixin Applied - Should be centered with purple background
</span>
</div>
</div>
)
}
4 changes: 4 additions & 0 deletions e2e/react-start/css-modules/src/styles/app.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// Import the mixin, which should make them available to future imports
@import './center-mixin.scss';

@import './mixin-consumer.scss';
5 changes: 5 additions & 0 deletions e2e/react-start/css-modules/src/styles/center-mixin.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
@mixin center-mixin {
display: flex;
justify-content: center;
align-items: center;
}
10 changes: 10 additions & 0 deletions e2e/react-start/css-modules/src/styles/mixin-consumer.scss
Original file line number Diff line number Diff line change
@@ -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;
}
38 changes: 38 additions & 0 deletions e2e/react-start/css-modules/tests/css.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 }) => {
Expand Down
4 changes: 3 additions & 1 deletion e2e/react-start/css-modules/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
],
}
})
1 change: 1 addition & 0 deletions e2e/solid-start/css-modules/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
7 changes: 7 additions & 0 deletions e2e/solid-start/css-modules/src/routes/__root.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,13 @@ function RootComponent() {
>
CSS Modules
</Link>
<Link
to="/sass-mixin"
style={{ color: '#0284c7', 'text-decoration': 'none' }}
data-testid="nav-sass-mixin"
>
Sass Mixin
</Link>
</nav>

<main style={{ padding: '20px' }}>
Expand Down
24 changes: 24 additions & 0 deletions e2e/solid-start/css-modules/src/routes/sass-mixin.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { createFileRoute } from '@tanstack/solid-router'
import '~/styles/app.scss'

export const Route = createFileRoute('/sass-mixin')({
component: SassMixin,
})

function SassMixin() {
return (
<div>
<h1>CSS Collection Test - Sass Mixin</h1>
<p>
This page tests that Sass mixins imported in a parent file are available
to subsequent imports during dev mode SSR.
</p>

<div class="mixin-container" data-testid="mixin-styled">
<span data-testid="mixin-content">
Sass Mixin Applied - Should be centered with purple background
</span>
</div>
</div>
)
}
4 changes: 4 additions & 0 deletions e2e/solid-start/css-modules/src/styles/app.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// Import the mixin, which should make them available to future imports
@import './center-mixin.scss';

@import './mixin-consumer.scss';
5 changes: 5 additions & 0 deletions e2e/solid-start/css-modules/src/styles/center-mixin.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
@mixin center-mixin {
display: flex;
justify-content: center;
align-items: center;
}
10 changes: 10 additions & 0 deletions e2e/solid-start/css-modules/src/styles/mixin-consumer.scss
Original file line number Diff line number Diff line change
@@ -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;
}
38 changes: 38 additions & 0 deletions e2e/solid-start/css-modules/tests/css.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 }) => {
Expand Down
1 change: 1 addition & 0 deletions e2e/vue-start/css-modules/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"@tanstack/router-e2e-utils": "workspace:*",
"@types/node": "^22.10.2",
"@vitejs/plugin-vue-jsx": "^4.1.2",
"sass": "^1.97.2",
"srvx": "^0.10.0",
"typescript": "^5.7.2",
"vite": "^7.1.7",
Expand Down
7 changes: 7 additions & 0 deletions e2e/vue-start/css-modules/src/routes/__root.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,13 @@ function RootComponent() {
>
CSS Modules
</Link>
<Link
to="/sass-mixin"
style={{ color: '#0284c7', textDecoration: 'none' }}
data-testid="nav-sass-mixin"
>
Sass Mixin
</Link>
</nav>

<main style={{ padding: '20px' }}>
Expand Down
24 changes: 24 additions & 0 deletions e2e/vue-start/css-modules/src/routes/sass-mixin.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { createFileRoute } from '@tanstack/vue-router'
import '~/styles/app.scss'

export const Route = createFileRoute('/sass-mixin')({
component: SassMixin,
})

function SassMixin() {
return (
<div>
<h1>CSS Collection Test - Sass Mixin</h1>
<p>
This page tests that Sass mixins imported in a parent file are available
to subsequent imports during dev mode SSR.
</p>

<div class="mixin-container" data-testid="mixin-styled">
<span data-testid="mixin-content">
Sass Mixin Applied - Should be centered with purple background
</span>
</div>
</div>
)
}
4 changes: 4 additions & 0 deletions e2e/vue-start/css-modules/src/styles/app.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// Import the mixin, which should make them available to future imports
@import './center-mixin.scss';

@import './mixin-consumer.scss';
5 changes: 5 additions & 0 deletions e2e/vue-start/css-modules/src/styles/center-mixin.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
@mixin center-mixin {
display: flex;
justify-content: center;
align-items: center;
}
10 changes: 10 additions & 0 deletions e2e/vue-start/css-modules/src/styles/mixin-consumer.scss
Original file line number Diff line number Diff line change
@@ -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;
}
38 changes: 38 additions & 0 deletions e2e/vue-start/css-modules/tests/css.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,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 }) => {
Expand Down
Loading
Loading