New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

postcss-split-by-media

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

postcss-split-by-media

Split CSS by @media with PostCSS

latest
Source
npmnpm
Version
0.3.0
Version published
Maintainers
1
Created
Source

PostCSS split CSS by Media Queries

Look through the test results to see how files are manipulated and split.

Caveats

This plugin does not and can never know which other plugins have preceded it and which plugins need to be run after it.

Since it also leaves white space where CSS used to be it is best to use a two stage processing pipeline.

First transform your CSS to a good baseline (e.g. postcss-preset-env, postcss-nesting, ...) with this plugin last.

Then run a second stage to finalize your CSS (e.g. cssnano, sourcemaps, ...).

Use the manifest json file or the manifest callback to get the list of files from the first stage.

Options

{
	onManifest: (manifest) => {
		console.log(manifest);
	}
}

In action

input :

.foo {
	color: red;
}

@media (min-width: 240px) {
	.foo {
		color: blue;
	}
}

output file a :

.foo {
	color: red;
}

output file b :

@media (min-width: 240px) {
	.foo {
		color: blue;
	}
}

manifest :

[
    {
        "base": "breakpoint.result.css",
        "media": ""
    }
    {
        "base": "breakpoint.result.at-media-min-width-240px.css",
        "media": "(min-width: 240px)"
    },
]

Supports

  • @media rules inside @supports
  • @supports rules inside @media
  • same for all other and future combinations
  • sourcemaps

Does not support and will never support

Nested CSS (because you shouldn't be nesting CSS) Transform to normal CSS before passing CSS to this plugin.

Keywords

PostCSS

FAQs

Package last updated on 07 Jun 2022

Did you know?

Socket

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.

Install

Related posts