Webpack-dev-server: [webpack v4] - default to './src/' if entry is not provided

Created on 16 Feb 2018  路  7Comments  路  Source: webpack/webpack-dev-server

  • 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()
    ]
}
approved bug

All 7 comments

@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.

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!

Alright I'll try and get this done today.

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)

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

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.

Fixed in [email protected], thanks again @rynclark!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

antoinerousseau picture antoinerousseau  路  3Comments

eyakcn picture eyakcn  路  3Comments

subblue picture subblue  路  3Comments

hnqlvs picture hnqlvs  路  3Comments

MJ111 picture MJ111  路  3Comments