diff --git a/packages/unocss-plugin/lib/index.js b/packages/unocss-plugin/lib/index.js index 74054bbad2..c26cb6ba11 100644 --- a/packages/unocss-plugin/lib/index.js +++ b/packages/unocss-plugin/lib/index.js @@ -94,8 +94,8 @@ function normalizeOptions (options) { // web配置 // todo config读取逻辑通过UnoCSSWebpackPlugin内置逻辑进行,待改进 webOptions = { - include: scan.include || [], - exclude: scan.exclude || [], + include: scan.include, + exclude: scan.exclude, transformers: [ ...transformGroups ? [transformerVariantGroup(transformGroups)] : [], ...transformCSS ? [transformerDirectives()] : [] diff --git a/packages/unocss-plugin/lib/web-plugin/utils.js b/packages/unocss-plugin/lib/web-plugin/utils.js index dfdabcc510..fe57447c93 100644 --- a/packages/unocss-plugin/lib/web-plugin/utils.js +++ b/packages/unocss-plugin/lib/web-plugin/utils.js @@ -27,9 +27,10 @@ function createContext (configOrPath, defaults = {}, extraConfigSources = []) { const result = await config.loadConfig(root, configOrPath, extraConfigSources, defaults) rawConfig = result.config uno.setConfig(rawConfig) + // plugin配置 > uno.config文件 > defualt rollupFilter = pluginutils.createFilter( - rawConfig.include || defaultInclude, - rawConfig.exclude || defaultExclude + configOrPath.include || rawConfig.include || defaultInclude, + configOrPath.exclude || rawConfig.exclude || defaultExclude ) const presets = /* @__PURE__ */ new Set() uno.config.presets.forEach((i) => { @@ -81,7 +82,9 @@ function createContext (configOrPath, defaults = {}, extraConfigSources = []) { if (code.includes(IGNORE_COMMENT)) { return false } - return code.includes(INCLUDE_COMMENT) || code.includes(CSS_PLACEHOLDER) || rollupFilter(id.replace(/\?v=\w+$/, '')) + // rollupFilter不支持query,所以直接过滤掉query匹配 + const path = id.split('?')[0] + return code.includes(INCLUDE_COMMENT) || code.includes(CSS_PLACEHOLDER) || rollupFilter(path) } return {