Skip to content
Open
Changes from 3 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
9 changes: 6 additions & 3 deletions packages/unocss-plugin/lib/web-plugin/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Copy link
Collaborator

@hiyuki hiyuki Dec 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

为啥需要加这个,我理解如果configOrPath是个config的话loadConfig就会直接作为结果返回了吧

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

loadConfig 里 config 和 path是互斥的,用了 config,就不再读 path了。这里本意是想对齐小程序的实现,先通过scan筛选文件,再走uno默认逻辑(即读取 uno.config 配置处理token)。

configOrPath.exclude || rawConfig.exclude || defaultExclude
)
const presets = /* @__PURE__ */ new Set()
uno.config.presets.forEach((i) => {
Expand Down Expand Up @@ -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 {
Expand Down