Skip to content

Commit

Permalink
fix unocss scan watch
Browse files Browse the repository at this point in the history
  • Loading branch information
hiyuki committed Nov 22, 2023

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
1 parent 5460efb commit a410486
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions packages/unocss-plugin/lib/index.js
Original file line number Diff line number Diff line change
@@ -56,7 +56,7 @@ function normalizeRules (rules, root) {
rules = [rules]
}
return rules.map((rule) => {
if (rule instanceof RegExp) {
if (typeof rule.test === 'function') {
return rule
}
if (typeof rule === 'string') {
@@ -126,6 +126,9 @@ function normalizeOptions (options) {
...escapeMap
}

scan.include = normalizeRules(scan.include, root)
scan.exclude = normalizeRules(scan.exclude, root)

return {
unoFile,
styleIsolation,
@@ -374,19 +377,13 @@ class MpxUnocssPlugin {
assets[file] = source
}

// normalize scan
const scan = this.options.scan
const root = this.options.root
scan.include = normalizeRules(scan.include, root)
scan.exclude = normalizeRules(scan.exclude, root)

await Promise.all(Object.entries(assets).map(([file, source]) => {
if (file.endsWith(styleExt) || file.endsWith(templateExt)) {
const assetModules = assetsModulesMap.get(file)
if (has(assetModules, (module) => {
if (module.resource) {
const resourcePath = toPosix(parseRequest(module.resource).resourcePath)
return filterFile(resourcePath, scan)
return filterFile(resourcePath, this.options.scan)
}
return false
})) {

0 comments on commit a410486

Please sign in to comment.