Skip to content

Commit

Permalink
fix: fix matchGlobs function to correctly handle negation patterns,…
Browse files Browse the repository at this point in the history
… fix vite-vue3/vite.config.ts import paths
  • Loading branch information
卢海宇 committed Jun 27, 2024
1 parent f6d7990 commit aebb8bb
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
4 changes: 2 additions & 2 deletions examples/vite-vue3/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import type { UserConfig } from 'vite'
import Vue from '@vitejs/plugin-vue'
import Components from 'unplugin-vue-components/vite'
import { VantResolver } from 'unplugin-vue-components/resolvers'
import Markdown from 'vite-plugin-vue-markdown'
import Markdown from 'unplugin-vue-markdown/vite'
import Icons from 'unplugin-icons/vite'
import IconsResolver from 'unplugin-icons/resolver'
import Inspect from 'vite-plugin-inspect'
Expand All @@ -18,7 +18,7 @@ const config: UserConfig = {
Vue({
include: [/\.vue$/, /\.md$/],
}),
Markdown(),
Markdown({}),
Icons(),
Inspect(),
Components({
Expand Down
8 changes: 5 additions & 3 deletions src/core/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,10 @@ export function isEmpty(value: any) {

export function matchGlobs(filepath: string, globs: string[]) {
for (const glob of globs) {
if (minimatch(slash(filepath), glob))
return true
const isNegated = glob.startsWith('!')
const match = minimatch(slash(filepath), isNegated ? glob.slice(1) : glob)
if (match)
return !isNegated
}
return false
}
Expand Down Expand Up @@ -143,7 +145,7 @@ export function getNameFromFilePath(filePath: string, options: ResolvedOptions):
if (globalNamespaces.some((name: string) => folders.includes(name)))
folders = folders.filter(f => !globalNamespaces.includes(f))

folders = folders.map(f => f.replace(/[^a-zA-Z0-9\-]/g, ''))
folders = folders.map(f => f.replace(/[^a-z0-9\-]/gi, ''))

if (filename.toLowerCase() === 'index')
filename = ''
Expand Down

0 comments on commit aebb8bb

Please sign in to comment.