Add defaults for entry and output in WebpackOptionsDefaulter.

I’m submitting a feature request

Webpack version:

Please tell us about your environment:
OSX 10.x / Linux / Windows 10

Current behavior:
You must specify at minimum an entry property and an output property.

Expected/desired behavior:
Do we really need to? Or could these be generic properties. I imagine the following by default:

(THIS IS JUST AN EXAMPLE, not what it really needs to be).

entry: {
  main: './src/index.js'
output: {
  filename: '[name].bundle.js',
  path: 'dist'
  • What is the motivation / use case for changing the behavior?
    tl;dr: @gaearon suggested this to me and I agree that we could make a sensible default for these two values. In the end do things like input and output always get changed, most likely, yes. But there’s also no reason to not have a default.
  • Browser: [all | Chrome XX | Firefox XX | IE XX | Safari XX | Mobile Chrome XX | Android X.X Web Browser | iOS XX Safari | iOS XX UIWebView | iOS XX WKWebView ]
  • Language: [all | TypeScript X.X | ES6/7 | ES5 | Dart | …]

Author: Fantashit

3 thoughts on “Add defaults for entry and output in WebpackOptionsDefaulter.

  1. I would warn against trying to support 5 different popular conventions. People are confused by Webpack precisely because its inputs are too relaxed and break subtly in unexpected ways. Pick one convention and run with it. It’s just a default after all.

    As for looking for “main” field this could be confusing because “main” should usually point to compiled output, not the source.

  2. I’d go against a default value for entry:

    • For some reason executing just webpack feels more magical than webpack ./src/index.js (with no webpack.config.js). Maybe this is me but this looks too implicit and thus confusing.
    • It doesn’t seem to be the widely used convention to have ./src/index.js as an entry.
    • The fact that we need to think if we need different defaults for entry depending on target feels wrong. That does suggest that there’s no default.

    I’m all for having a default value for output but I’d rather make it put all build artefacts into a directory, for example build/. That way it is easy to get rid of them — just rm -r build/ — I think this is important.

Comments are closed.