From fb23aa40eb7b5683af51f1eb55d0ca6a932a60c6 Mon Sep 17 00:00:00 2001 From: "devid.farinelli@gmail.com" Date: Sat, 20 Apr 2019 17:36:58 +0200 Subject: [PATCH] misc(init-generator): improve types & defaults --- INIT.md | 2 +- packages/generators/init-generator.ts | 12 ++++++++---- packages/generators/utils/entry.ts | 2 +- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/INIT.md b/INIT.md index bc9350b8245..8dd9a3a7099 100644 --- a/INIT.md +++ b/INIT.md @@ -1,6 +1,6 @@ # webpack-cli init -`webpack-cli init` is used to initialize `webpack` projects quickly by scaffolding configuration and a runnable project with all the dependencies based on the user preferences. +`webpack-cli init` is used to initialize `webpack` projects quickly by scaffolding configuration and creating a runnable project with all the dependencies based on the user preferences. ## Initial Setup diff --git a/packages/generators/init-generator.ts b/packages/generators/init-generator.ts index d3a458307bb..d06a1efa097 100644 --- a/packages/generators/init-generator.ts +++ b/packages/generators/init-generator.ts @@ -151,15 +151,19 @@ export default class InitGenerator extends Generator { return this.prompt([ Confirm("multiEntries", "Will your application have multiple bundles?", false), ]) - .then((multiEntriesAnswer: any) => + .then((multiEntriesAnswer: { + multiEntries: boolean, + }) => entryQuestions(self, multiEntriesAnswer.multiEntries), ) .then((entryOption: object | string) => { if (typeof entryOption === "string" && entryOption.length > 0) { this.configuration.config.webpackOptions.entry = `${entryOption}`; + } else if (typeof entryOption === "object") { + this.configuration.config.webpackOptions.entry = entryOption; } }) - .then((_: void) => + .then(() => this.prompt([ Input( "outputDir", @@ -191,7 +195,7 @@ export default class InitGenerator extends Generator { `path.resolve(__dirname, '${outputDirAnswer.outputDir}')`; } }) - .then((_: void) => + .then(() => this.prompt([ Confirm("useBabel", "Will you be using ES2015?"), ]), @@ -210,7 +214,7 @@ export default class InitGenerator extends Generator { ); } }) - .then((_: void) => + .then(() => this.prompt([ List("stylingType", "Will you use one of the below CSS solutions?", [ "No", diff --git a/packages/generators/utils/entry.ts b/packages/generators/utils/entry.ts index 5f136e0b940..e9cb3d85587 100644 --- a/packages/generators/utils/entry.ts +++ b/packages/generators/utils/entry.ts @@ -104,7 +104,7 @@ export default function entry(self: CustomGenerator, multiEntries: boolean): Pro `${entryProp}`, `What is the location of "${entryProp}"?`, validate, - `./src/${entryProp}`, + `src/${entryProp}`, ), ]), ).then((entryPropAnswer: object): object => {