Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,20 @@ const extractScope = (options) => {
return null;
}

const scopify = (options) => {
const scopify = (options, { exclude = [] } = {}) => {
const excludePatterns = exclude.map(pattern => {
return pattern instanceof RegExp ? pattern : new RegExp(pattern);
});

return {
postcssPlugin: 'postcss-scopify',
Once (root, { result }) {
const filePath = result.opts.from || '';
// Use regular expressions to check if a file is in the exclusion list.
if (excludePatterns.some(pattern => pattern.test(filePath))) {
return;
}

const scope = extractScope(options);
// guard statment- allow only valid scopes
if(!isValidScope(scope)){
Expand Down