Skip to content

Conversation

@simonsmith
Copy link
Member

This allows users to add plugins to the existing array as normal, but also gives them control over re-ordering existing ones.

Currently object-assign-deep just concats arrays, which means there is no order control.

Say for example I need stylelint to run before autoprefixer:

// defaults
[
    'postcss-import',
    'postcss-custom-properties',
    'postcss-calc',
    'postcss-custom-media',
    'autoprefixer',
    'postcss-reporter'
  ]

// config
{use: ['stylelint', 'autoprefixer', 'postcss-reporter']}

// result
[
    'postcss-import',
    'postcss-custom-properties',
    'postcss-calc',
    'postcss-custom-media',
    'stylelint',
    'autoprefixer',
    'postcss-reporter'
  ]

This could also be useful to re-order the existing plugins if needed.

// config
{use: ['autoprefixer', 'postcss-at2x', 'postcss-calc', 'postcss-reporter']}

// result
[
  'postcss-import',
  'postcss-custom-properties',
  'postcss-custom-media',
  'autoprefixer',
  'postcss-at2x',
  'postcss-calc',
  'postcss-reporter'
]

This need came out of trying to get stylelint to work and having autoprefixer get in the way, but I think it's a nice enhancement anyway.

I removed the check for postcss-reporter being last, because now the user has control over that easily.

Also made the lodash dependency smaller by using the individual packages, but annoyingly I think postcss-reporter uses the full library anyway.

@giuseppeg If this looks good I'll update the README too :)

* Also remove lodash library and just use single packages from npm
@giuseppeg
Copy link
Member

@simonsmith yeah it looks good! I wonder if deepmerge was doing that already.

@simonsmith
Copy link
Member Author

Good question! I will investigate first

@simonsmith
Copy link
Member Author

It does dedupe arrays, but not in the way that would work for this - http://jsbin.com/genuci/edit?js,console

@giuseppeg
Copy link
Member

fair enough, I just asked out of curiosity ;)

@simonsmith
Copy link
Member Author

Would have been handy!

simonsmith added a commit that referenced this pull request Nov 24, 2015
Allow re-ordering of the plugins array via config
@simonsmith simonsmith merged commit aa4d0c0 into master Nov 24, 2015
@simonsmith simonsmith deleted the plugin-order branch November 24, 2015 22:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants