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 v4] - default to './src/' if entry is not provided #1308

Closed
TheLarkInn opened this issue Feb 16, 2018 · 7 comments
Closed

[webpack v4] - default to './src/' if entry is not provided #1308

TheLarkInn opened this issue Feb 16, 2018 · 7 comments

Comments

@TheLarkInn
Copy link
Member

  • webpack Version: "@next"
  • webpack-dev-server Version: "@next"
  • [ x ] This is a bug

Code

const HtmlWebpackPlugin = require("html-webpack-plugin");

module.exports = {
    mode: "development",
    plugins: [
        new HtmlWebpackPlugin()
    ]
}
@TheLarkInn
Copy link
Member Author

@SpaceK33z I searched for a little bit in the code but couldn't find where the best place to make this change would be. I'm happy to PR it, or theres probably others who would too, if you just want to leave a note which part of the code we could default this value.

Essentailly WebpackOptionsApply now is responsible for defaulting the entry if it isnt provided (#0CJS) so we should find a way to respect this.

@SpaceK33z
Copy link
Member

Thanks for your report! Interesting, this does work when you use the API but not with the CLI. The fix should be made somewhere in bin/webpack-dev-server.js. Somewhere there it seems to trigger webpack's options schema validation without the defaults being applied beforehand.

A PR is very welcome!

@TheLarkInn
Copy link
Member Author

Alright I'll try and get this done today.

@TheLarkInn
Copy link
Member Author

For those wanting to contribute:

  • look in file @SpaceK33z mentioned above, allow webpack default entry to be set by preventing the premature schema validation

Valid test scenario:

  • a user can run webpack-dev-server on a project not using a config (only criteria would be a index.js file inside of ./src folder)

@ryanclark
Copy link
Member

I think this lies more with the webpack-cli rather than the dev server.

I've submitted a PR here that adds the default entry point in the CLI, meaning we're not modifying the config in the dev server

@ryanclark
Copy link
Member

Ignore that last comment, the issue lies with the dev server.

The dev server will generate a small webpack config if not given one (or if given one), that adds the lib/client/js/index.js as an entry point, and then undefined too if you don't pass it.

@ryanclark ryanclark mentioned this issue Feb 17, 2018
5 tasks
@SpaceK33z
Copy link
Member

Fixed in webpack-dev-server@3.0.0-beta.2, thanks again @rynclark!

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

No branches or pull requests

3 participants