@@ -43,6 +43,11 @@ export default (opts = {}) => {
4343 } ) ) ;
4444 }
4545
46+ const outPath = path . resolve ( dirCwd , args . output ) ;
47+ const pathTsConf = rootResolve ( 'tsconfig.json' ) ;
48+ const tsConfig = fs . existsSync ( pathTsConf ) ? require ( pathTsConf ) : { } ;
49+ const optsTsCmpl = tsConfig . compilerOptions || { } ;
50+
4651 let config = {
4752 entry : path . resolve ( dirCwd , args . entry ) ,
4853 mode : isProd ? 'production' : 'development' ,
@@ -62,14 +67,28 @@ export default (opts = {}) => {
6267 } ) ] ,
6368 } ,
6469 output : {
65- path : path . resolve ( dirCwd , args . output ) ,
70+ path : outPath ,
6671 filename : `${ name } .min.js` ,
6772 library : name ,
6873 libraryTarget : 'umd' ,
6974 globalObject : `typeof globalThis !== 'undefined' ? globalThis : (typeof window !== 'undefined' ? window : this)` ,
7075 } ,
7176 module : {
7277 rules : [ {
78+ test : / \. t s x ? $ / ,
79+ loader : require . resolve ( 'ts-loader' ) ,
80+ exclude : / n o d e _ m o d u l e s / ,
81+ options : {
82+ context : rootResolve ( '' ) ,
83+ configFile : pathTsConf ,
84+ compilerOptions : {
85+ ...(
86+ optsTsCmpl . declaration && ! optsTsCmpl . declarationDir &&
87+ { declarationDir : `${ outPath } /types` }
88+ )
89+ }
90+ }
91+ } , {
7392 test : / \. j s $ / ,
7493 loader : 'babel-loader' ,
7594 include : / s r c / ,
@@ -80,6 +99,9 @@ export default (opts = {}) => {
8099 } ,
81100 } ] ,
82101 } ,
102+ resolve : {
103+ extensions : [ '.tsx' , '.ts' , '.js' ] ,
104+ } ,
83105 plugins : plugins ,
84106 } ;
85107
0 commit comments