Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG]: 馃悶init command doesnt change the entryOptions value when passed #884

Closed
anikethsaha opened this issue May 16, 2019 · 2 comments 路 Fixed by #817
Closed

[BUG]: 馃悶init command doesnt change the entryOptions value when passed #884

anikethsaha opened this issue May 16, 2019 · 2 comments 路 Fixed by #817

Comments

@anikethsaha
Copy link
Member

anikethsaha commented May 16, 2019

Describe the bug

What is the current behavior?
in $ npx webpack-cli init command, In the second question, it is asking for the entry point and the default is dist but if we write the entrypoint in the answer then also it is keeping dist only in the webpack.config.js which is generated

To Reproduce
Steps to reproduce the behavior:

  1. RUN : $ npx webpack-cli init
  2. In 1st question , select n and then in the second question Which module will be the first to enter the application? [default: ./src/index] give any path for entry like ./index.js or any path or filename
  3. in the webpack.config.js file generated, it won't write any entry property as it is taking the dist which is the default one

Expected behavior

It should have an entry property with the value as the answer passed for 2nd question in a path resolved method

Fix
line causing the bug:
in this line
The first if statement will run always even though it is getting '[file-or-pathname]' from here as it will always return '' and its length will be greater than 0 and type is always string

To Fix this :
in line change replacing the existing with this one work fine.

		.then(
				(entryOptions: object | string): Promise<{}> => {
					if (typeof entryOptions === "string" && entryOptions.length > 0) {
						
						if (entryOptions !== "\"\"" &&  entryOptions !== "\'\'") {
							this.configuration.config.webpackOptions.entry = entryOptions;
						}
					}
			
					return this.prompt([
						Input("outputType", "In which folder do you want to store your generated bundles? (dist):")
					]);
				}
			)

I have tested this and it's working fine in all types of answers for that.

Please paste the results of webpack-cli info here, and mention other relevant information

  System:
    OS: Windows 10
    CPU: (4) x64 Intel(R) Core(TM) i5-6200U CPU @ 2.30GHz
  Binaries:
    Yarn: 1.15.2 - C:\Program Files (x86)\Yarn\bin\yarn.CMD
    npm: 6.9.0 - C:\Program Files\nodejs\npm.CMD

Updated
Changed the step to reproduce question to correct one.

@anikethsaha
Copy link
Member Author

The if statement can be better if we use more effecient regex like this one :

if(!(/(\'\'|\"\")/g.test(entryOptions))){
...
}

@anikethsaha
Copy link
Member Author

cc @ematipico @evenstensberg

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants