| |
| new file mode 100644 |
| |
| |
| |
| @@ -0,0 +1,11 @@ |
| +@custom-media --narrow (max-width: 960px); |
| + |
| +.box { |
| + color: blue; |
| +} |
| + |
| +@media (--narrow) { |
| + .box { |
| + color: red; |
| + } |
| +} |
| |
| new file mode 100644 |
| |
| |
| |
| @@ -0,0 +1,5 @@ |
| +import styles from './page.module.css' |
| + |
| +export default function Page() { |
| + return <div className={styles.box}>Custom media</div> |
| +} |
| |
| |
| |
| |
| @@ -23,7 +23,7 @@ describe('experimental-lightningcss-features', () => { |
| describe('include', () => { |
| const { next } = nextTestSetup({ |
| files: __dirname, |
| - dependencies: { lightningcss: '^1.23.0' }, |
| + dependencies: { lightningcss: '1.33.0' }, |
| // Chrome 123 supports light-dark() natively — using it here proves that |
| // the `include` flag forces transpilation regardless of browser support. |
| packageJson: { |
| @@ -52,10 +52,38 @@ describe('experimental-lightningcss-features', () => { |
| }) |
| }) |
| |
| + describe('custom-media-queries', () => { |
| + const { next } = nextTestSetup({ |
| + files: __dirname, |
| + dependencies: { lightningcss: '1.33.0' }, |
| + packageJson: { |
| + browserslist: ['chrome 123'], |
| + }, |
| + nextConfig: { |
| + experimental: { |
| + useLightningcss: true, |
| + lightningCssFeatures: { |
| + include: ['custom-media-queries'], |
| + }, |
| + }, |
| + }, |
| + }) |
| + |
| + it('should substitute @custom-media when custom-media-queries is included', async () => { |
| + const html = await next.render('/custom-media') |
| + expect(html).toContain('Custom media') |
| + |
| + const css = await collectPageCss(next, '/custom-media') |
| + expect(css).not.toContain('@custom-media') |
| + expect(css).not.toContain('--narrow') |
| + expect(css).toMatch(/max-width:\s*960px|width\s*<=\s*960px/) |
| + }) |
| + }) |
| + |
| describe('exclude', () => { |
| const { next } = nextTestSetup({ |
| files: __dirname, |
| - dependencies: { lightningcss: '^1.23.0' }, |
| + dependencies: { lightningcss: '1.33.0' }, |
| // Chrome 100 does NOT support light-dark() natively, so lightningcss would |
| // normally transpile it. Using `exclude: ['light-dark']` should prevent that. |
| packageJson: { |
|
|