postcss-global-nested

Wrap styles into :global like postcss-nested does it but for unstandard :global selector

Downloads in past

Stats

StarsIssuesVersionUpdatedCreatedSize
postcss-global-nested
121.2.07 years ago7 years agoMinified + gzip package size for postcss-global-nested in KB

Readme

postcss-global-nested Build Status
Wrap styles into a :global like postcss-nested does it for usual selectors.
You should use :global as rare as you can.

usage

test.css:
:global {
  .foo {}
  .bar {}
}

Use it with postcss, postcss-nested and webpack

{
  loader: 'postcss-loader',
  options: {
    plugins: [
      require('autoprefixer')({
        browsers: ['last 2 version'],
      }),
      require('postcss-nested')({}),
      require('postcss-global-nested')({}),
    ],
  },
}

Use it w/ vanilla postcss and postcss-nested

import pcss from 'postcss';
import nested from 'postcss-nested';
import globalNested from 'postcss-global-nested';

(async () => {
  const css = await util.promisify(fs.readFile)('test.css', 'utf8');
  const result = await pcss([nested, globalNested]).process(css);
  result.css // -> ':global(.foo) {} :global(.bar) {}'
 })();