Skip to content

Commit 155ed56

Browse files
feat: adds support for custom CSS media queries (#306)
* feat: added CSS custom media query support * refactor: added PostCssCustom media for dev-stage and prod webpack configs `@edx/frontend-build` now supports custom CSS media queries in order to support media query definitions using CSS variables (not natively supported by CSS). To do so, it uses PostCSS Custom Media to let you define `@custom-media` in CSS following the Custom Media Specification: https://www.w3.org/TR/mediaqueries-5/#at-ruledef-custom-media.
1 parent ca69358 commit 155ed56

5 files changed

+122
-0
lines changed

config/webpack.dev-stage.config.js

+2
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ const HtmlWebpackPlugin = require('html-webpack-plugin');
99
const path = require('path');
1010
const PostCssAutoprefixerPlugin = require('autoprefixer');
1111
const PostCssRTLCSS = require('postcss-rtlcss');
12+
const PostCssCustomMediaCSS = require('postcss-custom-media');
1213
const ReactRefreshWebpackPlugin = require('@pmmmwh/react-refresh-webpack-plugin');
1314

1415
const commonConfig = require('./webpack.common.config');
@@ -84,6 +85,7 @@ module.exports = merge(commonConfig, {
8485
plugins: [
8586
PostCssAutoprefixerPlugin(),
8687
PostCssRTLCSS(),
88+
PostCssCustomMediaCSS(),
8789
],
8890
},
8991
},

config/webpack.dev.config.js

+2
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ const HtmlWebpackPlugin = require('html-webpack-plugin');
99
const path = require('path');
1010
const PostCssAutoprefixerPlugin = require('autoprefixer');
1111
const PostCssRTLCSS = require('postcss-rtlcss');
12+
const PostCssCustomMediaCSS = require('postcss-custom-media');
1213
const ReactRefreshWebpackPlugin = require('@pmmmwh/react-refresh-webpack-plugin');
1314

1415
const commonConfig = require('./webpack.common.config');
@@ -85,6 +86,7 @@ module.exports = merge(commonConfig, {
8586
plugins: [
8687
PostCssAutoprefixerPlugin(),
8788
PostCssRTLCSS(),
89+
PostCssCustomMediaCSS(),
8890
],
8991
},
9092
},

config/webpack.prod.config.js

+2
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ const MiniCssExtractPlugin = require('mini-css-extract-plugin');
1515
const path = require('path');
1616
const PostCssAutoprefixerPlugin = require('autoprefixer');
1717
const PostCssRTLCSS = require('postcss-rtlcss');
18+
const PostCssCustomMediaCSS = require('postcss-custom-media');
1819

1920
const HtmlWebpackNewRelicPlugin = require('../lib/plugins/html-webpack-new-relic-plugin');
2021
const commonConfig = require('./webpack.common.config');
@@ -106,6 +107,7 @@ module.exports = merge(commonConfig, {
106107
PostCssAutoprefixerPlugin(),
107108
PostCssRTLCSS(),
108109
CssNano(),
110+
PostCssCustomMediaCSS(),
109111
],
110112
},
111113
},

package-lock.json

+115
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@
6161
"jest": "26.6.3",
6262
"mini-css-extract-plugin": "1.6.2",
6363
"postcss": "8.4.21",
64+
"postcss-custom-media": "^9.1.2",
6465
"postcss-loader": "6.2.1",
6566
"postcss-rtlcss": "3.7.2",
6667
"react-dev-utils": "12.0.1",

0 commit comments

Comments
 (0)