@@ -9,7 +9,7 @@ import { Confirm, Input, List } from "@webpack-cli/webpack-scaffold";
9
9
10
10
import { WebpackOptions } from "./types" ;
11
11
import entryQuestions from "./utils/entry" ;
12
- import langQuestionHandler from "./utils/language" ;
12
+ import langQuestionHandler , { LangType } from "./utils/language" ;
13
13
import styleQuestionHandler , { Loader , StylingType } from "./utils/style" ;
14
14
import tooltip from "./utils/tooltip" ;
15
15
@@ -33,6 +33,7 @@ export default class InitGenerator extends Generator {
33
33
webpackOptions ?: WebpackOptions ;
34
34
} ;
35
35
} ;
36
+ private langType : string ;
36
37
37
38
public constructor ( args , opts ) {
38
39
super ( args , opts ) ;
@@ -187,13 +188,14 @@ export default class InitGenerator extends Generator {
187
188
188
189
const { langType } : { langType : string } = await this . prompt ( [
189
190
List ( "langType" , "Will you use one of the below JS solutions?" , [
190
- " ES6" ,
191
- " Typescript" ,
191
+ LangType . ES6 ,
192
+ LangType . Typescript ,
192
193
"No" ,
193
194
] ) ,
194
195
] ) ;
195
196
196
197
langQuestionHandler ( this , langType ) ;
198
+ this . langType = langType ;
197
199
198
200
const { stylingType } : { stylingType : string } = await this . prompt ( [
199
201
List ( "stylingType" , "Will you use one of the below CSS solutions?" , [
@@ -270,7 +272,6 @@ export default class InitGenerator extends Generator {
270
272
const packageJsonTemplatePath = "./templates/package.json.js" ;
271
273
this . fs . extendJSON ( this . destinationPath ( "package.json" ) , require ( packageJsonTemplatePath ) ( this . isProd ) ) ;
272
274
273
- const entry = this . configuration . config . webpackOptions . entry ;
274
275
const generateEntryFile = ( entryPath : string , name : string ) : void => {
275
276
entryPath = entryPath . replace ( / ' / g, "" ) ;
276
277
this . fs . copyTpl (
@@ -280,12 +281,19 @@ export default class InitGenerator extends Generator {
280
281
) ;
281
282
} ;
282
283
284
+ // Generate entry file/files
285
+ const entry = this . configuration . config . webpackOptions . entry ;
283
286
if ( typeof entry === "string" ) {
284
287
generateEntryFile ( entry , "your main file!" ) ;
285
288
} else if ( typeof entry === "object" ) {
286
289
Object . keys ( entry ) . forEach ( ( name : string ) : void =>
287
290
generateEntryFile ( entry [ name ] , `${ name } main file!` ) ,
288
291
) ;
289
292
}
293
+
294
+ if ( this . langType === LangType . Typescript ) {
295
+ const tsConfigTemplatePath = "./templates/tsconfig.json.js" ;
296
+ this . fs . extendJSON ( this . destinationPath ( "tsconfig.json" ) , require ( tsConfigTemplatePath ) ) ;
297
+ }
290
298
}
291
299
}
0 commit comments