1+ import { Rule } from "../types" ;
2+
13export enum LangType {
24 ES6 = "ES6" ,
35 Typescript = "Typescript" ,
46}
57
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-
198const replaceExt = ( path : string , ext : string ) : string =>
209 path . substr ( 0 , path . lastIndexOf ( "." ) ) + `${ ext } '` ;
2110
@@ -54,14 +43,14 @@ function getEntryFolders(self): string[] {
5443 *
5544 * Returns an module.rule object for the babel loader
5645 * @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
5847 */
59- export function getBabelLoader ( includeFolders : string [ ] ) : ModuleRule {
48+ export function getBabelLoader ( includeFolders : string [ ] ) : Rule {
6049 const include = includeFolders . map ( ( folder : string ) : string =>
6150 `path.resolve(__dirname, '${ folder } ')`
6251 ) ;
6352 return {
64- test : "/\.js $/" ,
53+ test : "/\.(js|jsx) $/" ,
6554 include,
6655 loader : "'babel-loader'" ,
6756 options : {
@@ -82,14 +71,14 @@ export function getBabelLoader(includeFolders: string[]): ModuleRule {
8271 *
8372 * Returns an module.rule object for the typescript loader
8473 * @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
8675 */
87- export function getTypescriptLoader ( includeFolders : string [ ] ) : ModuleRule {
76+ export function getTypescriptLoader ( includeFolders : string [ ] ) : Rule {
8877 const include = includeFolders . map ( ( folder : string ) : string =>
8978 `path.resolve(__dirname, '${ folder } ')`
9079 ) ;
9180 return {
92- test : "/\.tsx?$/" ,
81+ test : "/\.(ts| tsx) ?$/" ,
9382 loader : "'ts-loader'" ,
9483 include,
9584 exclude : [ "/node_modules/" ] ,
0 commit comments