From 10aa36533f5eaecf4baaf95515d45760ab624d62 Mon Sep 17 00:00:00 2001 From: Adam Wathan Date: Fri, 22 Feb 2019 09:50:36 -0500 Subject: [PATCH] Pass postcss to plugins explicitly --- __tests__/processPlugins.test.js | 12 ++++++------ src/util/processPlugins.js | 1 + 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/__tests__/processPlugins.test.js b/__tests__/processPlugins.test.js index 740bc0fcb..3d342d502 100644 --- a/__tests__/processPlugins.test.js +++ b/__tests__/processPlugins.test.js @@ -1,9 +1,9 @@ import _ from 'lodash' -import postcss from 'postcss' +import _postcss from 'postcss' import processPlugins from '../src/util/processPlugins' function css(nodes) { - return postcss.root({ nodes }).toString() + return _postcss.root({ nodes }).toString() } function makeConfig(overrides) { @@ -97,7 +97,7 @@ test('plugins can create utilities with arrays of objects', () => { test('plugins can create utilities with raw PostCSS nodes', () => { const { components, utilities } = processPlugins( [ - function({ addUtilities }) { + function({ addUtilities, postcss }) { addUtilities([ postcss.rule({ selector: '.object-fill' }).append([ postcss.decl({ @@ -142,7 +142,7 @@ test('plugins can create utilities with raw PostCSS nodes', () => { test('plugins can create utilities with mixed object styles and PostCSS nodes', () => { const { components, utilities } = processPlugins( [ - function({ addUtilities }) { + function({ addUtilities, postcss }) { addUtilities([ { '.object-fill': { @@ -259,7 +259,7 @@ test('plugins can create components with object syntax', () => { test('plugins can create components with raw PostCSS nodes', () => { const { components, utilities } = processPlugins( [ - function({ addComponents }) { + function({ addComponents, postcss }) { addComponents([ postcss.rule({ selector: '.btn-blue' }).append([ postcss.decl({ @@ -308,7 +308,7 @@ test('plugins can create components with raw PostCSS nodes', () => { test('plugins can create components with mixed object styles and raw PostCSS nodes', () => { const { components, utilities } = processPlugins( [ - function({ addComponents }) { + function({ addComponents, postcss }) { addComponents([ postcss.rule({ selector: '.btn-blue' }).append([ postcss.decl({ diff --git a/src/util/processPlugins.js b/src/util/processPlugins.js index 07c9d3024..5d64c3eaf 100644 --- a/src/util/processPlugins.js +++ b/src/util/processPlugins.js @@ -22,6 +22,7 @@ export default function(plugins, config) { plugins.forEach(plugin => { plugin({ + postcss, config: (path, defaultValue) => _.get(config, path, defaultValue), e: escapeClassName, prefix: selector => {