1
- import { join , parse } from 'path'
1
+ import { join , parse , resolve } from 'path'
2
2
import minimatch from 'minimatch'
3
3
import { ResolvedConfig } from 'vite'
4
4
import { ComponentInfo , ResolvedOptions , Options } from './types'
@@ -75,7 +75,7 @@ export function stringifyComponentImport({ name, path, importName }: ComponentIn
75
75
return `import ${ name } from '${ path } '`
76
76
}
77
77
78
- export function resolveOptions ( options : Options ) : ResolvedOptions {
78
+ export function resolveOptions ( options : Options , viteConfig : ResolvedConfig ) : ResolvedOptions {
79
79
const resolved = Object . assign ( { } , defaultOptions , options ) as ResolvedOptions
80
80
resolved . libraries = toArray ( resolved . libraries ) . map ( i => typeof i === 'string' ? { name : i } : i )
81
81
resolved . customComponentResolvers = toArray ( resolved . customComponentResolvers )
@@ -87,6 +87,7 @@ export function resolveOptions(options: Options): ResolvedOptions {
87
87
: `{${ resolved . extensions . join ( ',' ) } }`
88
88
89
89
resolved . dirs = toArray ( resolved . dirs )
90
+ resolved . resolvedDirs = resolved . dirs . map ( i => resolve ( viteConfig . root , i ) )
90
91
91
92
resolved . globs = resolved . dirs . map ( i =>
92
93
resolved . deep
@@ -101,14 +102,14 @@ export function resolveOptions(options: Options): ResolvedOptions {
101
102
}
102
103
103
104
export function getNameFromFilePath ( filePath : string , options : ResolvedOptions ) : string {
104
- const { dirs , directoryAsNamespace, globalNamespaces } = options
105
+ const { resolvedDirs , directoryAsNamespace, globalNamespaces } = options
105
106
106
107
const parsedFilePath = parse ( filePath )
107
108
108
109
let strippedPath = ''
109
110
110
111
// remove include directories from filepath
111
- for ( const dir of dirs ) {
112
+ for ( const dir of resolvedDirs ) {
112
113
if ( parsedFilePath . dir . startsWith ( dir ) ) {
113
114
strippedPath = parsedFilePath . dir . slice ( dir . length )
114
115
break
0 commit comments