Skip to content

Commit 938fad0

Browse files
committed
custom media extensions
1 parent b2c7434 commit 938fad0

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

packages/react-scripts/config/webpack.config.dev.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ const postcssApplyRuleSets = {
5555
font-size: var(--h1-mobile-font-size);
5656
line-height: var(--h1-mobile-line-height);
5757
58-
@media (min-width: var(--tablet-min-width)) {
58+
@media (--tablet-min-width) {
5959
font-size: var(--h1-font-size);
6060
line-height: var(--h1-line-height);
6161
}
@@ -74,6 +74,11 @@ const postcssApplyRuleSets = {
7474
`,
7575
};
7676

77+
const postcssCustomMediaExtensions = {
78+
// var(--tablet-min-width) did not work
79+
'--tablet-min-width': `(min-width: ${theme.global.tabletMinWidth})`,
80+
};
81+
7782
const postCSSLoaderOptions = {
7883
ident: 'postcss', // https://webpack.js.org/guides/migrating/#complex-options
7984
plugins: loader => [
@@ -98,6 +103,9 @@ const postCSSLoaderOptions = {
98103
applyRule: {
99104
sets: postcssApplyRuleSets,
100105
},
106+
customMedia: {
107+
extensions: postcssCustomMediaExtensions,
108+
},
101109
},
102110
}),
103111
],

packages/react-scripts/template/src/components/example/index.css

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,11 @@
3131

3232
.appLogo {
3333
animation: spin infinite 20s linear;
34-
height: 80px;
34+
height: 50px;
35+
36+
@media (--tablet-min-width) {
37+
height: 80px;
38+
}
3539
}
3640

3741

0 commit comments

Comments
 (0)