-
Notifications
You must be signed in to change notification settings - Fork 73
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs: CSS modules named imports example (#2206)
- Loading branch information
1 parent
442a12e
commit 771ff92
Showing
7 changed files
with
73 additions
and
16 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,27 @@ | ||
import { build, gotoPage, rspackOnlyTest } from '@e2e/helper'; | ||
import { expect } from '@playwright/test'; | ||
|
||
rspackOnlyTest( | ||
'should compile CSS modules with named exports correctly', | ||
async ({ page }) => { | ||
const rsbuild = await build({ | ||
cwd: __dirname, | ||
runServer: true, | ||
}); | ||
const files = await rsbuild.unwrapOutputJSON(); | ||
|
||
const content = | ||
files[Object.keys(files).find((file) => file.endsWith('.css'))!]; | ||
|
||
expect(content).toMatch( | ||
/\.classA-\w{6}{color:red}\.classB-\w{6}{color:blue}\.classC-\w{6}{color:yellow}/, | ||
); | ||
|
||
await gotoPage(page, rsbuild); | ||
const root = page.locator('#root'); | ||
const text = await root.innerHTML(); | ||
|
||
expect(text).toMatch(/classA-\w{6} classB-\w{6} classC-\w{6}/); | ||
await rsbuild.close(); | ||
}, | ||
); |
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 @@ | ||
.classA { | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
.classB { | ||
color: blue; | ||
} |
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 @@ | ||
.classC { | ||
color: yellow; | ||
} |
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 @@ | ||
import { classA } from './a.module.css'; | ||
import { classB } from './b.module.scss'; | ||
import { classC } from './c.module.less'; | ||
|
||
const root = document.querySelector('#root'); | ||
|
||
if (root) { | ||
root.innerHTML = `${classA} ${classB} ${classC}`; | ||
} |
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