Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(css) add experimental webpack CSS support
- Loading branch information
Showing
5 changed files
with
219 additions
and
3 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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
import { createNext } from 'e2e-utils' | ||
import { NextInstance } from 'test/lib/next-modes/base' | ||
import webdriver from 'next-webdriver' | ||
|
||
describe('CSS webpack Experiment', () => { | ||
describe('with basic CSS', () => { | ||
let next: NextInstance | ||
|
||
beforeAll(async () => { | ||
next = await createNext({ | ||
files: { | ||
'styles/global.css': ` | ||
p { | ||
color: green; | ||
font-size: 2rem; | ||
} | ||
`, | ||
'styles/styles.module.css': ` | ||
.hello { | ||
color: red; | ||
} | ||
`, | ||
'styles/styles.module.sass': ` | ||
$color: blue | ||
.hello | ||
color: $color | ||
`, | ||
'pages/_app.js': ` | ||
import '../styles/global.css'; | ||
export default function MyApp({ Component, pageProps }) { | ||
return <Component {...pageProps} /> | ||
} | ||
`, | ||
'pages/index.js': ` | ||
export default function Page() { | ||
return <p>hello world</p> | ||
} | ||
`, | ||
'pages/css-modules.js': ` | ||
import * as styles from '../styles/styles.module.css'; | ||
export default function Page() { | ||
return <p className={styles.hello}>hello world</p> | ||
} | ||
`, | ||
'pages/sass.js': ` | ||
import * as styles from '../styles/styles.module.sass'; | ||
export default function Page() { | ||
return <p className={styles.hello}>hello world</p> | ||
} | ||
`, | ||
}, | ||
nextConfig: { | ||
experimental: { | ||
webpackCssExperiment: true, | ||
}, | ||
}, | ||
dependencies: { | ||
sass: '1.52.3', | ||
}, | ||
}) | ||
}) | ||
|
||
afterAll(() => next.destroy()) | ||
|
||
it('should work with basic CSS', async () => { | ||
const browser = await webdriver(next.url, `/`) | ||
const element = await browser.elementByCss('p') | ||
const color = await element.getComputedCss('color') | ||
|
||
expect(color).toBe('rgb(0, 128, 0)') | ||
}) | ||
|
||
it('should work with CSS modules', async () => { | ||
const browser = await webdriver(next.url, `/css-modules`) | ||
const element = await browser.elementByCss('p') | ||
const color = await element.getComputedCss('color') | ||
|
||
expect(color).toBe('rgb(255, 0, 0)') | ||
}) | ||
|
||
it('should work with SASS', async () => { | ||
const browser = await webdriver(next.url, `/sass`) | ||
const element = await browser.elementByCss('p') | ||
const color = await element.getComputedCss('color') | ||
|
||
expect(color).toBe('rgb(0, 0, 255)') | ||
}) | ||
}) | ||
}) |