diff --git a/nesting/plugin.js b/nesting/plugin.js index 72bb24c27d33..2b5586648464 100644 --- a/nesting/plugin.js +++ b/nesting/plugin.js @@ -14,7 +14,10 @@ module.exports = function nesting(opts = postcssNested) { }) let plugin = (() => { - if (typeof opts === 'function') { + if ( + typeof opts === 'function' || + (typeof opts === 'object' && opts?.hasOwnProperty('postcssPlugin')) + ) { return opts } diff --git a/tests/postcss-plugins/nesting/index.test.js b/tests/postcss-plugins/nesting/index.test.js index 03f184de14b2..2fcfb731d71a 100644 --- a/tests/postcss-plugins/nesting/index.test.js +++ b/tests/postcss-plugins/nesting/index.test.js @@ -74,7 +74,7 @@ it('should default to the bundled postcss-nested plugin (no options)', async () `) }) -it('should default to the bundled postcss-nested plugin (empty ooptions)', async () => { +it('should default to the bundled postcss-nested plugin (empty options)', async () => { let input = css` .foo { color: black; @@ -97,6 +97,29 @@ it('should default to the bundled postcss-nested plugin (empty ooptions)', async `) }) +it('should be possible to use postcss-nested plugin with options', async () => { + let input = css` + .foo { + color: black; + @screen md { + color: blue; + } + } + ` + + expect(await run(input, postcssNested({ noIsPseudoSelector: true }))).toMatchCss(css` + .foo { + color: black; + } + + @media screen(md) { + .foo { + color: blue; + } + } + `) +}) + test('@screen rules are replaced with media queries', async () => { let input = css` .foo {