Skip to content

Commit 6eff655

Browse files
committed
fix: outBase of single file
1 parent 95bdae5 commit 6eff655

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/index.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -103,11 +103,10 @@ export const plugin: UnpluginInstance<Options | undefined, false> =
103103
rollup: {
104104
options(rollupOptions) {
105105
let outBase = ''
106-
const input = rollupOptions.input
106+
let input = rollupOptions.input
107+
input = typeof input === 'string' ? [input] : input
107108
if (Array.isArray(input)) {
108109
outBase = lowestCommonAncestor(...input)
109-
} else if (typeof input === 'string') {
110-
outBase = path.dirname(input)
111110
}
112111

113112
if (!contexts.length) contexts.push({} as any)
@@ -124,7 +123,8 @@ export const plugin: UnpluginInstance<Options | undefined, false> =
124123
export default plugin
125124

126125
function lowestCommonAncestor(...filepaths: string[]) {
127-
if (filepaths.length <= 1) return ''
126+
if (filepaths.length === 0) return ''
127+
if (filepaths.length === 1) return path.dirname(filepaths[0])
128128
const [first, ...rest] = filepaths
129129
let ancestor = first.split(path.sep)
130130
for (const filepath of rest) {

0 commit comments

Comments
 (0)