Skip to content

Commit

Permalink
Fix toggling of plugins in presets using boolean configuration option
Browse files Browse the repository at this point in the history
  • Loading branch information
andyjansson committed Oct 2, 2018
1 parent 793a37d commit 5b57cd4
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
11 changes: 11 additions & 0 deletions packages/cssnano/src/__tests__/presets.js
Expand Up @@ -82,6 +82,17 @@ test('should be able to exclude plugins', t => {
});
});

test('should be able to include plugins', t => {
const preset = [
'advanced',
{zindex: true},
];

return cssnano.process(`h1{z-index:10}`, {}, {preset}).then(result => {
t.is(result.css, `h1{z-index:1}`);
});
});

test('should be able to exclude plugins (exclude syntax)', t => {
const preset = [
'advanced',
Expand Down
3 changes: 2 additions & 1 deletion packages/cssnano/src/index.js
Expand Up @@ -11,7 +11,8 @@ function initializePlugin (plugin, css, result) {
const [processor, opts] = plugin;
if (
typeof opts === 'undefined' ||
(typeof opts === 'object' && !opts.exclude)
(typeof opts === 'object' && !opts.exclude) ||
(typeof opts === 'boolean' && opts === true)
) {
return Promise.resolve(
processor(opts)(css, result)
Expand Down

0 comments on commit 5b57cd4

Please sign in to comment.