From 9171415f7ac08592481e06990b679d08c029b27b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E7=87=83=E4=B8=9C?= Date: Tue, 18 Feb 2025 19:32:58 +0800 Subject: [PATCH 1/3] feat: Add support for "exclude". --- index.js | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index ba42223..659594d 100644 --- a/index.js +++ b/index.js @@ -56,10 +56,23 @@ const extractScope = (options) => { return null; } -const scopify = (options) => { +const scopify = (options, { exclude = [] } = {}) => { + // 将 exclude 模式转换为 RegExp 对象 + 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 || ''; + + // 使用正则表达式检查文件是否在排除列表中 + if (excludePatterns.some(pattern => pattern.test(filePath))) { + return; + } + const scope = extractScope(options); // guard statment- allow only valid scopes if(!isValidScope(scope)){ From bd09406217297fcd416a7700f6de8e0c4e1666cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E7=87=83=E4=B8=9C?= Date: Tue, 18 Feb 2025 19:37:53 +0800 Subject: [PATCH 2/3] test --- index.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/index.js b/index.js index 659594d..30ecc29 100644 --- a/index.js +++ b/index.js @@ -68,6 +68,8 @@ const scopify = (options, { exclude = [] } = {}) => { // 获取当前处理的文件路径 const filePath = result.opts.from || ''; + console.log(filePath) + // 使用正则表达式检查文件是否在排除列表中 if (excludePatterns.some(pattern => pattern.test(filePath))) { return; From 1c3ff2a0870c7939f558d27a152681b786649018 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E7=87=83=E4=B8=9C?= Date: Tue, 18 Feb 2025 20:05:37 +0800 Subject: [PATCH 3/3] feat: Add support for "exclude". --- index.js | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/index.js b/index.js index 30ecc29..f08f27b 100644 --- a/index.js +++ b/index.js @@ -57,7 +57,6 @@ const extractScope = (options) => { } const scopify = (options, { exclude = [] } = {}) => { - // 将 exclude 模式转换为 RegExp 对象 const excludePatterns = exclude.map(pattern => { return pattern instanceof RegExp ? pattern : new RegExp(pattern); }); @@ -65,12 +64,8 @@ const scopify = (options, { exclude = [] } = {}) => { return { postcssPlugin: 'postcss-scopify', Once (root, { result }) { - // 获取当前处理的文件路径 const filePath = result.opts.from || ''; - - console.log(filePath) - - // 使用正则表达式检查文件是否在排除列表中 + // Use regular expressions to check if a file is in the exclusion list. if (excludePatterns.some(pattern => pattern.test(filePath))) { return; }