Skip to content

Commit 4332408

Browse files
committed
fix: custom dts filename
closes #40
1 parent 6aea1ad commit 4332408

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/generate.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,10 +108,14 @@ export function createGeneratePlugin({
108108
(typeof options.entryFileNames === 'function'
109109
? options.entryFileNames(chunk)
110110
: options.entryFileNames) || '[name].js'
111-
if (!original.includes('.d') && chunk.name.endsWith('.d')) {
112-
return original.replace(RE_JS, '.$1ts')
111+
112+
if (!chunk.name.endsWith('.d')) return original
113+
114+
// already a dts file
115+
if (RE_DTS.test(original)) {
116+
return original.replace('[name]', chunk.name.slice(0, -2))
113117
}
114-
return original
118+
return original.replace(RE_JS, '.$1ts')
115119
},
116120
}
117121
},

0 commit comments

Comments
 (0)