Skip to content

Commit

Permalink
feat: adds support for custom CSS media queries (#306)
Browse files Browse the repository at this point in the history
* 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.
  • Loading branch information
PKulkoRaccoonGang authored Feb 24, 2023
1 parent ca69358 commit 155ed56
Show file tree
Hide file tree
Showing 5 changed files with 122 additions and 0 deletions.
2 changes: 2 additions & 0 deletions config/webpack.dev-stage.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const HtmlWebpackPlugin = require('html-webpack-plugin');
const path = require('path');
const PostCssAutoprefixerPlugin = require('autoprefixer');
const PostCssRTLCSS = require('postcss-rtlcss');
const PostCssCustomMediaCSS = require('postcss-custom-media');
const ReactRefreshWebpackPlugin = require('@pmmmwh/react-refresh-webpack-plugin');

const commonConfig = require('./webpack.common.config');
Expand Down Expand Up @@ -84,6 +85,7 @@ module.exports = merge(commonConfig, {
plugins: [
PostCssAutoprefixerPlugin(),
PostCssRTLCSS(),
PostCssCustomMediaCSS(),
],
},
},
Expand Down
2 changes: 2 additions & 0 deletions config/webpack.dev.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const HtmlWebpackPlugin = require('html-webpack-plugin');
const path = require('path');
const PostCssAutoprefixerPlugin = require('autoprefixer');
const PostCssRTLCSS = require('postcss-rtlcss');
const PostCssCustomMediaCSS = require('postcss-custom-media');
const ReactRefreshWebpackPlugin = require('@pmmmwh/react-refresh-webpack-plugin');

const commonConfig = require('./webpack.common.config');
Expand Down Expand Up @@ -85,6 +86,7 @@ module.exports = merge(commonConfig, {
plugins: [
PostCssAutoprefixerPlugin(),
PostCssRTLCSS(),
PostCssCustomMediaCSS(),
],
},
},
Expand Down
2 changes: 2 additions & 0 deletions config/webpack.prod.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const path = require('path');
const PostCssAutoprefixerPlugin = require('autoprefixer');
const PostCssRTLCSS = require('postcss-rtlcss');
const PostCssCustomMediaCSS = require('postcss-custom-media');

const HtmlWebpackNewRelicPlugin = require('../lib/plugins/html-webpack-new-relic-plugin');
const commonConfig = require('./webpack.common.config');
Expand Down Expand Up @@ -106,6 +107,7 @@ module.exports = merge(commonConfig, {
PostCssAutoprefixerPlugin(),
PostCssRTLCSS(),
CssNano(),
PostCssCustomMediaCSS(),
],
},
},
Expand Down
115 changes: 115 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
"jest": "26.6.3",
"mini-css-extract-plugin": "1.6.2",
"postcss": "8.4.21",
"postcss-custom-media": "^9.1.2",
"postcss-loader": "6.2.1",
"postcss-rtlcss": "3.7.2",
"react-dev-utils": "12.0.1",
Expand Down

0 comments on commit 155ed56

Please sign in to comment.