-
Notifications
You must be signed in to change notification settings - Fork 351
Commit
Co-authored-by: Asuka109 <chenwenjie.asuka@bytedance.com>
- Loading branch information
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import path from 'path'; | ||
import { expect, test } from '@modern-js/e2e/playwright'; | ||
import { build } from '@scripts/shared'; | ||
|
||
test('should compile CSS modules composes correctly', async () => { | ||
const builder = await build({ | ||
cwd: __dirname, | ||
entry: { index: path.resolve(__dirname, './src/index.js') }, | ||
}); | ||
const files = await builder.unwrapOutputJSON(); | ||
|
||
const content = | ||
files[Object.keys(files).find(file => file.endsWith('.css'))!]; | ||
|
||
if (builder.providerType === 'rspack') { | ||
expect(content).toMatch( | ||
/.*\{background:red;color:yellow\}.*\{background:blue\}/, | ||
); | ||
} else { | ||
expect(content).toMatch( | ||
/.*\{background:red;color:#ff0\}.*\{background:blue\}/, | ||
); | ||
} | ||
}); | ||
|
||
test('should compile CSS modules composes with external correctly', async () => { | ||
const builder = await build({ | ||
cwd: __dirname, | ||
entry: { external: path.resolve(__dirname, './src/external.js') }, | ||
}); | ||
const files = await builder.unwrapOutputJSON(); | ||
|
||
const content = | ||
files[Object.keys(files).find(file => file.endsWith('.css'))!]; | ||
|
||
if (builder.providerType === 'rspack') { | ||
expect(content).toMatch( | ||
/.*\{background:cyan;color:black\}.*\{background:green\}/, | ||
); | ||
} else { | ||
expect(content).toMatch( | ||
/.*\{background:cyan;color:#000\}.*\{background:green\}/, | ||
); | ||
} | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import styles from './external.module.css'; | ||
|
||
console.log(styles); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
.subClass2 { | ||
composes: className from './other.module.css'; | ||
background: green; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import styles from './index.module.css'; | ||
|
||
console.log(styles); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
.className { | ||
background: cyan; | ||
color: black; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import path from 'path'; | ||
import { expect, test } from '@modern-js/e2e/playwright'; | ||
import { build } from '@scripts/shared'; | ||
|
||
test('should compile CSS modules with :global() correctly', async () => { | ||
const builder = await build({ | ||
cwd: __dirname, | ||
entry: { index: path.resolve(__dirname, './src/index.js') }, | ||
}); | ||
const files = await builder.unwrapOutputJSON(); | ||
|
||
const content = | ||
files[Object.keys(files).find(file => file.endsWith('.css'))!]; | ||
|
||
expect(content).toMatch( | ||
/.*\{position:relative\}.* \.bar,.* \.baz\{height:100%;overflow:hidden\}.* \.lol{width:80%}/, | ||
); | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
import './a.module.css'; |
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.