File size: 3,192 Bytes
94786da | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 | 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 <div className={styles.box}>Custom media</div>
+}
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: {
|