@@ -9,7 +9,7 @@ import { Confirm, Input, List } from "@webpack-cli/webpack-scaffold";
99
1010import { WebpackOptions } from "./types" ;
1111import entryQuestions from "./utils/entry" ;
12- import langQuestionHandler from "./utils/language" ;
12+ import langQuestionHandler , { LangType } from "./utils/language" ;
1313import styleQuestionHandler , { Loader , StylingType } from "./utils/style" ;
1414import tooltip from "./utils/tooltip" ;
1515
@@ -33,6 +33,7 @@ export default class InitGenerator extends Generator {
3333 webpackOptions ?: WebpackOptions ;
3434 } ;
3535 } ;
36+ private langType : string ;
3637
3738 public constructor ( args , opts ) {
3839 super ( args , opts ) ;
@@ -187,13 +188,14 @@ export default class InitGenerator extends Generator {
187188
188189 const { langType } : { langType : string } = await this . prompt ( [
189190 List ( "langType" , "Will you use one of the below JS solutions?" , [
190- " ES6" ,
191- " Typescript" ,
191+ LangType . ES6 ,
192+ LangType . Typescript ,
192193 "No" ,
193194 ] ) ,
194195 ] ) ;
195196
196197 langQuestionHandler ( this , langType ) ;
198+ this . langType = langType ;
197199
198200 const { stylingType } : { stylingType : string } = await this . prompt ( [
199201 List ( "stylingType" , "Will you use one of the below CSS solutions?" , [
@@ -270,7 +272,6 @@ export default class InitGenerator extends Generator {
270272 const packageJsonTemplatePath = "./templates/package.json.js" ;
271273 this . fs . extendJSON ( this . destinationPath ( "package.json" ) , require ( packageJsonTemplatePath ) ( this . isProd ) ) ;
272274
273- const entry = this . configuration . config . webpackOptions . entry ;
274275 const generateEntryFile = ( entryPath : string , name : string ) : void => {
275276 entryPath = entryPath . replace ( / ' / g, "" ) ;
276277 this . fs . copyTpl (
@@ -280,12 +281,19 @@ export default class InitGenerator extends Generator {
280281 ) ;
281282 } ;
282283
284+ // Generate entry file/files
285+ const entry = this . configuration . config . webpackOptions . entry ;
283286 if ( typeof entry === "string" ) {
284287 generateEntryFile ( entry , "your main file!" ) ;
285288 } else if ( typeof entry === "object" ) {
286289 Object . keys ( entry ) . forEach ( ( name : string ) : void =>
287290 generateEntryFile ( entry [ name ] , `${ name } main file!` ) ,
288291 ) ;
289292 }
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+ }
290298 }
291299}
0 commit comments