Skip to content
This repository was archived by the owner on Aug 8, 2023. It is now read-only.
This repository was archived by the owner on Aug 8, 2023. It is now read-only.

Feature Suggestion: "Exclude" option #6

@gmhenderson

Description

@gmhenderson

Hello. Thank you for the very useful plugin. In my case, however, I needed the ability to exclude certain selectors from receiving the prefix. I modified the code a bit and added an exclude option, which should be an array of RegExp's against which to test the selectors, before prepending anything:

...

var selectorExcluded = function (regexp) {
  return regexp.test(selector)
}

if (selector.startsWith(opts.selector.trim()) || opts.exclude.some(selectorExcluded)) {
  return selector
}

return opts.selector + selector

...

which could be used like:

require('postcss-prepend-selector')({ selector: '.my-stuff ', exclude: [/#content-wrapper/] })

It seems to be working, so I thought I'd share the idea in case you're interested in incorporating into the plugin.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions