
Product
Introducing Webhook Events for Alert Changes
Add real-time Socket webhook events to your workflows to automatically receive software supply chain alert changes in real time.
postcss-include-media
Advanced tools
PostCSS plugin to output @media definitions from include-media format.
PostCSS plugin to output css @media definitions based on SASS mixin include-media format
Step 1: Install plugins:
npm install --save-dev postcss postcss-nesting postcss-include-media
Step 2: Check you project for existed PostCSS config: postcss.config.js
in the project root, "postcss" section in package.json
or postcss in bundle config.
If you do not use PostCSS, add it according to official docs and set this plugin in settings.
Step 3: Add the plugin to plugins list:
+ const postcssIncludeMedia = require('postcss-include-media');
module.exports = {
plugins: [
+ require('postcss-nesting'),
+ postcssIncludeMedia(),
require('autoprefixer')
]
}
breakpointsIf you want to change them or add more, you can simply re-declare breakpoints using the Sass map syntax.
type Record<key: string>
optional: true
defaults:
{ phone: '320px', tablet: '768px', desktop: '1024px' }
usage:
postcssIncludeMedia({
breakpoints: {
md: '700px',
xl: '1200px,
}
}),
mediaExpressionsMedia types and static expressions are optional and automatically deferred. The list of media types can be modified by declaring mediaExpressions.
Expressions containing logical disjunctions, such as Chris Coyier's retina declaration, are correctly handled, even when combined with other media types or breakpoints.
type Record<key: string>
optional: true
defaults:
{
screen: 'screen',
print: 'print',
all: 'all',
handheld: 'handheld',
landscape: '(orientation: landscape)',
portrait: '(orientation: portrait)',
retina2x: '(-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi), (min-resolution: 2dppx)',
retina3x: '(-webkit-min-device-pixel-ratio: 3), (min-resolution: 350dpi), (min-resolution: 3dppx)',
}
usage:
postcssIncludeMedia({
mediaExpressions: {
retina: '(-webkit-min-device-pixel-ratio: 2)',
}
}),
unitIntervalsDefines a number to be added or subtracted from each unit when declaring breakpoints with inclusive/exclusive intervals
type Record<key: number>
optional: true
defaults:
{
px: 1,
em: 0.01,
rem: 0.1,
'': 0,
}
usage:
postcssIncludeMedia({
unitIntervals: {
'%': 1,
}
}),
ruleNameDefines a the rule name you wish to use for the detection of breakpoints. EG for @include media('>phone') set ruleName: 'include media'. While this is supported by the plugin, its not recommended, as could cause issues with other plugins.
type string
optional: true
defaults:
'include-media'
usage:
// allows rules to be used
// @banana ('>=md') { .test { content: '' } }
postcssIncludeMedia({
ruleName: 'banana'
}),
Input
@include-media('>=phone') {
.foo {
/* Input example */
}
}
@include-media('<desktop') {
.bar {
/* Input example */
}
}
Output
@media (min-width: 320px) {
.foo {
/* Output example */
}
}
@media (max-width: 1023px) {
.bar {
/* Input example */
}
}
Input
@include-media('>123px') {
.foo {
/* Input example */
}
}
Output
@media (min-width: 124px) {
.foo {
/* Output example */
}
}
Input
@include-media('>=desktop', 'retina2x') {
.foo {
/* Input example */
}
}
Output
@media (min-width: 1024px) and (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi), (min-resolution: 2dppx) {
.foo {
/* Output example */
}
}
Credit to the original Authors of include-media both Eduardo Boucas and Kitty Giraudel
1.1.1
FAQs
PostCSS plugin to output @media definitions from include-media format.
We found that postcss-include-media demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Product
Add real-time Socket webhook events to your workflows to automatically receive software supply chain alert changes in real time.

Security News
ENISA has become a CVE Program Root, giving the EU a central authority for coordinating vulnerability reporting, disclosure, and cross-border response.

Product
Socket now scans OpenVSX extensions, giving teams early detection of risky behaviors, hidden capabilities, and supply chain threats in developer tools.