diff --git a/test/e2e/app-dir/experimental-lightningcss-features/app/custom-media/page.module.css b/test/e2e/app-dir/experimental-lightningcss-features/app/custom-media/page.module.css new file mode 100644 index 00000000..743b745f --- /dev/null +++ b/test/e2e/app-dir/experimental-lightningcss-features/app/custom-media/page.module.css @@ -0,0 +1,11 @@ +@custom-media --narrow (max-width: 960px); + +.box { + color: blue; +} + +@media (--narrow) { + .box { + color: red; + } +} diff --git a/test/e2e/app-dir/experimental-lightningcss-features/app/custom-media/page.tsx b/test/e2e/app-dir/experimental-lightningcss-features/app/custom-media/page.tsx new file mode 100644 index 00000000..f4949f6d --- /dev/null +++ b/test/e2e/app-dir/experimental-lightningcss-features/app/custom-media/page.tsx @@ -0,0 +1,5 @@ +import styles from './page.module.css' + +export default function Page() { + return
Custom media
+} diff --git a/test/e2e/app-dir/experimental-lightningcss-features/experimental-lightningcss-features.test.ts b/test/e2e/app-dir/experimental-lightningcss-features/experimental-lightningcss-features.test.ts index ec5ec389..8173b8b6 100644 --- a/test/e2e/app-dir/experimental-lightningcss-features/experimental-lightningcss-features.test.ts +++ b/test/e2e/app-dir/experimental-lightningcss-features/experimental-lightningcss-features.test.ts @@ -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: {