diff --git a/__tests__/processPlugins.test.js b/__tests__/processPlugins.test.js index ae8aad847..f70c12e6f 100644 --- a/__tests__/processPlugins.test.js +++ b/__tests__/processPlugins.test.js @@ -1244,3 +1244,46 @@ test('plugins can be provided as an object with a handler function', () => { } `) }) + +test('plugins can provide a config but no handler', () => { + const { components, utilities } = processPlugins( + [ + { + config: { + prefix: 'tw-', + }, + }, + { + handler({ addUtilities }) { + addUtilities({ + '.object-fill': { + 'object-fit': 'fill', + }, + '.object-contain': { + 'object-fit': 'contain', + }, + '.object-cover': { + 'object-fit': 'cover', + }, + }) + }, + }, + ], + makeConfig() + ) + + expect(components.length).toBe(0) + expect(css(utilities)).toMatchCss(` + @variants { + .object-fill { + object-fit: fill + } + .object-contain { + object-fit: contain + } + .object-cover { + object-fit: cover + } + } + `) +}) diff --git a/__tests__/resolveConfig.test.js b/__tests__/resolveConfig.test.js index fb8d5edd6..4b0df5724 100644 --- a/__tests__/resolveConfig.test.js +++ b/__tests__/resolveConfig.test.js @@ -1367,7 +1367,6 @@ test('plugin config modifications are applied', () => { config: { prefix: 'tw-', }, - handler() {}, }, ], } @@ -1416,7 +1415,6 @@ test('user config takes precedence over plugin config modifications', () => { config: { prefix: 'tw-', }, - handler() {}, }, ], } @@ -1468,13 +1466,11 @@ test('plugin config can register plugins that also have config', () => { config: { important: true, }, - handler() {}, }, { config: { separator: '__', }, - handler() {}, }, ], }, @@ -1530,7 +1526,6 @@ test('plugin configs take precedence over plugin configs registered by that plug config: { prefix: 'inner-', }, - handler() {}, }, ], }, diff --git a/src/util/processPlugins.js b/src/util/processPlugins.js index 3618238cc..1dcd7f627 100644 --- a/src/util/processPlugins.js +++ b/src/util/processPlugins.js @@ -29,7 +29,7 @@ export default function(plugins, config) { const getConfigValue = (path, defaultValue) => _.get(config, path, defaultValue) plugins.forEach(plugin => { - const handler = isFunction(plugin) ? plugin : plugin.handler + const handler = isFunction(plugin) ? plugin : _.get(plugin, 'handler', () => {}) handler({ postcss,