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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

webpack entry config doesn't work if defaultEntry file existed #1288

Closed
Mistyyyy opened this issue Mar 4, 2020 · 2 comments · Fixed by #1289
Closed

webpack entry config doesn't work if defaultEntry file existed #1288

Mistyyyy opened this issue Mar 4, 2020 · 2 comments · Fixed by #1289

Comments

@Mistyyyy
Copy link
Contributor

Mistyyyy commented Mar 4, 2020

What is the current behavior?

webpack.config.js

module.exports = {
  mode: 'development',

  entry: {
    index: './src/entry.js',
  },

  output: {
    path: path.resolve(__dirname, 'dist'),
    filename: '[name].bundle.js',
  },

  plugins: [
    new CleanWebpackPlugin()
  ]
}

below is project Directory Structure

├── index.js
├── package.json
├── src
│   ├── a.js
│   └── entry.js
└── webpack.config.js

when running npx webpack, the output ismain.bundle.js , the content of the final bundle includes index.js module and excludes entry.js module

how I know this is a webpack-cli bug rather webpack bug

I debug the program locally

To Reproduce

https://github.com/Mistyyyy/webpack-cli-entry-repo

Expected behavior

output: index.bundle.js

Screenshots

image

I had fix it locally, the reason is BasicGroup has a default entry value and override the config entry value if find defaultEntry file.

If appropriate, I am willing to submit a PR

version

Node: v12.10.0
webpack: 5.0.0-beta.13
webpack-cli: 4.0.0-beta.8

@anshumanv
Copy link
Member

This is a bug surely, please feel free to submit a PR.

@ematipico
Copy link
Contributor

This is a nice chance for first contributors to tackle the issue. A good way to tackle issue would be to create a test first and make that fails.

Mistyyyy added a commit to Mistyyyy/webpack-cli that referenced this issue Mar 4, 2020
if not pass the entry option through command line, webpack-cli would look for defaultEntry
The
action would override the entry in webpack config files

ISSUES CLOSED: webpack#1288
Mistyyyy added a commit to Mistyyyy/webpack-cli that referenced this issue Mar 7, 2020
Mistyyyy added a commit to Mistyyyy/webpack-cli that referenced this issue Mar 7, 2020
To get the correct entry, the entry should use defaultEntry, config entry, command entry in order

ISSUES CLOSED: webpack#1288
ematipico pushed a commit that referenced this issue Mar 10, 2020
…try (#1289)

* fix(webpack-cli): to void defaultEntry override the webpack config entry

if not pass the entry option through command line, webpack-cli would look for defaultEntry
The
action would override the entry in webpack config files

ISSUES CLOSED: #1288

* chore(webpack-cli): remove the unused eslint comment and console statement

* tests(jest): rename the tests for entry-with command and entry-with-config

ISSUES CLOSED: #1288

* fix(bugs): to void defaultEntry override config entry

To get the correct entry, the entry should use defaultEntry, config entry, command entry in order

ISSUES CLOSED: #1288

* tests(entry): fix the word spelling of test case

* fix(bugs): execute the basicGroup only once
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants