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
27 changes: 27 additions & 0 deletions test/css-modules/index.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { dirname } from 'node:path';
import { fileURLToPath } from 'node:url';
import { expect, test } from '@playwright/test';
import { createRsbuild } from '@rsbuild/core';
import { pluginTailwindCSS } from '../../src';

const __dirname = dirname(fileURLToPath(import.meta.url));

test('can co-exist with CSS modules', async ({ page }) => {
const rsbuild = await createRsbuild({
cwd: __dirname,
rsbuildConfig: {
plugins: [pluginTailwindCSS()],
},
});

await rsbuild.build();
const { server, urls } = await rsbuild.preview();

await page.goto(urls[0]);

const locator = page.locator('#button');
await expect(locator).toHaveCSS('display', 'flex');
await expect(locator).toHaveCSS('color', 'rgb(17, 34, 51)');

await server.close();
});
3 changes: 3 additions & 0 deletions test/css-modules/src/components/Button.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.button {
color: #112233;
}
10 changes: 10 additions & 0 deletions test/css-modules/src/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import styles from './components/Button.module.css';

const root = document.getElementById('root');

const button = document.createElement('button');
button.id = 'button';
button.className = `flex ${styles.button}`;
button.textContent = 'CSS Modules button';

root.appendChild(button);