@@ -4,6 +4,36 @@ import dts from 'vite-plugin-dts'
44import path from 'node:path'
55
66export default defineConfig ( {
7+ plugins : [
8+ dts ( {
9+ beforeWriteFile : ( filePath , content ) => ( {
10+ content : content . replaceAll (
11+ / (?< importPath > (?: f r o m | i m p o r t \s * \( ) \s * [ " ' ] \. .* ?) (?< quote > [ " ' ] ) / gu,
12+ ( ...replaceArguments ) => {
13+ let { importPath, quote } = replaceArguments . at ( - 1 ) as {
14+ importPath : string
15+ quote : string
16+ }
17+ if ( importPath . endsWith ( '.js' ) || importPath . endsWith ( '.json' ) ) {
18+ return `${ importPath } ${ quote } `
19+ }
20+ return `${ importPath } .js${ quote } `
21+ } ,
22+ ) ,
23+ filePath,
24+ } ) ,
25+ include : [
26+ path . join ( import . meta. dirname , 'index.ts' ) ,
27+ path . join ( import . meta. dirname , 'types' ) ,
28+ path . join ( import . meta. dirname , 'rules' ) ,
29+ path . join ( import . meta. dirname , 'utils' ) ,
30+ ] ,
31+ insertTypesEntry : true ,
32+ copyDtsFiles : true ,
33+ strictOutput : true ,
34+ } ) ,
35+ prettierFormat ( ) ,
36+ ] ,
737 build : {
838 lib : {
939 entry : [
@@ -23,18 +53,4 @@ export default defineConfig({
2353 } ,
2454 minify : false ,
2555 } ,
26- plugins : [
27- dts ( {
28- include : [
29- path . join ( import . meta. dirname , 'index.ts' ) ,
30- path . join ( import . meta. dirname , 'types' ) ,
31- path . join ( import . meta. dirname , 'rules' ) ,
32- path . join ( import . meta. dirname , 'utils' ) ,
33- ] ,
34- insertTypesEntry : true ,
35- copyDtsFiles : true ,
36- strictOutput : true ,
37- } ) ,
38- prettierFormat ( ) ,
39- ] ,
4056} )
0 commit comments