11import { WebpackConfig , get } from '@easy-webpack/core'
22import * as path from 'path'
3- import { ForkCheckerPlugin } from 'awesome-typescript-loader'
4- import 'regenerator-runtime/runtime'
3+ import { ForkCheckerPlugin , TsConfigPathsPlugin } from 'awesome-typescript-loader'
54
65/**
76 * Typescript loader support for .ts
87 * See: https://github.com/s-panferov/awesome-typescript-loader
98 */
10- export = function typescript ( { options = { } , exclude = null } = { } ) {
9+ export = function typescript ( { options = undefined , exclude = null } = { } ) {
1110 return function typescript ( this : WebpackConfig ) : WebpackConfig {
11+ const loader = {
12+ test : / \. t s x ? $ / ,
13+ loader : 'awesome-typescript' ,
14+ exclude : exclude || this . metadata . root ? [ path . join ( this . metadata . root , 'node_modules' ) ] : [ ]
15+ } as any
16+
17+ if ( options ) {
18+ loader . query = options
19+ }
20+
1221 return {
1322 resolve : {
1423 extensions : get ( this , 'resolve.extensions' , [ '' , '.js' ] ) . concat ( [ '.ts' ] )
1524 } ,
1625 module : {
17- loaders : get ( this , 'module.loaders' , [ ] ) . concat ( [ {
18- test : / \. t s x ? $ / ,
19- loader : 'awesome-typescript' ,
20- exclude : exclude || this . metadata . root ? [ path . join ( this . metadata . root , 'node_modules' ) ] : [ ] ,
21- query : options
22- } ] )
26+ loaders : get ( this , 'module.loaders' , [ ] ) . concat ( [ loader ] )
2327 } ,
2428 plugins : [
2529 /*
@@ -28,7 +32,8 @@ export = function typescript({options = {}, exclude = null} = {}) {
2832 *
2933 * See: https://github.com/s-panferov/awesome-typescript-loader#forkchecker-boolean-defaultfalse
3034 */
31- new ForkCheckerPlugin ( )
35+ new ForkCheckerPlugin ( ) ,
36+ new TsConfigPathsPlugin ( options )
3237 ] . concat ( get ( this , 'plugins' , [ ] ) )
3338 }
3439 }
0 commit comments