1
+ import { Rule } from "../types" ;
2
+
1
3
export enum LangType {
2
4
ES6 = "ES6" ,
3
5
Typescript = "Typescript" ,
4
6
}
5
7
6
- interface ModuleRule extends Object {
7
- include ?: string [ ] ;
8
- exclude ?: string [ ] ;
9
- loader : string ;
10
- options ?: {
11
- plugins : string [ ] ;
12
- presets : Preset [ ] [ ] ;
13
- } ;
14
- test : string ;
15
- }
16
-
17
- type Preset = string | object ;
18
-
19
8
const replaceExt = ( path : string , ext : string ) : string =>
20
9
path . substr ( 0 , path . lastIndexOf ( "." ) ) + `${ ext } '` ;
21
10
@@ -54,14 +43,14 @@ function getEntryFolders(self): string[] {
54
43
*
55
44
* Returns an module.rule object for the babel loader
56
45
* @param {string[] } includeFolders An array of folders to include
57
- * @returns {ModuleRule } A configuration containing the babel-loader with env preset
46
+ * @returns {Rule } A configuration containing the babel-loader with env preset
58
47
*/
59
- export function getBabelLoader ( includeFolders : string [ ] ) : ModuleRule {
48
+ export function getBabelLoader ( includeFolders : string [ ] ) : Rule {
60
49
const include = includeFolders . map ( ( folder : string ) : string =>
61
50
`path.resolve(__dirname, '${ folder } ')`
62
51
) ;
63
52
return {
64
- test : "/\.js $/" ,
53
+ test : "/\.(js|jsx) $/" ,
65
54
include,
66
55
loader : "'babel-loader'" ,
67
56
options : {
@@ -82,14 +71,14 @@ export function getBabelLoader(includeFolders: string[]): ModuleRule {
82
71
*
83
72
* Returns an module.rule object for the typescript loader
84
73
* @param {string[] } includeFolders An array of folders to include
85
- * @returns {ModuleRule } A configuration containing the ts-loader
74
+ * @returns {Rule } A configuration containing the ts-loader
86
75
*/
87
- export function getTypescriptLoader ( includeFolders : string [ ] ) : ModuleRule {
76
+ export function getTypescriptLoader ( includeFolders : string [ ] ) : Rule {
88
77
const include = includeFolders . map ( ( folder : string ) : string =>
89
78
`path.resolve(__dirname, '${ folder } ')`
90
79
) ;
91
80
return {
92
- test : "/\.tsx?$/" ,
81
+ test : "/\.(ts| tsx) ?$/" ,
93
82
loader : "'ts-loader'" ,
94
83
include,
95
84
exclude : [ "/node_modules/" ] ,
0 commit comments