Unwrap container contents with PostCSS
$ npm install postcss-unwrap-helper
$ yarn add postcss-unwrap-helper
This is not a PostCSS plugin, just exposes a helper function that unwraps a node, preserving the correct whitespace.
import postcss from 'postcss';
import unwrapHelper from 'postcss-unwrap-helper';
// Am example plugin that unwraps all media queries
postcss.plugin('postcss-unwrap-all-media-queries', () => root => {
root.walkAtRules('media', unwrapHelper);
};
Input CSS:
@media screen and (min-width: 960px) {
div {
display: block;
}
}
span {
display: flex;
}
Output CSS:
div {
display: block;
}
span {
display: flex;
}