Skip to content
This repository has been archived by the owner on Feb 18, 2024. It is now read-only.

Cannot override main entry template without also specifying the path to the entry again #1178

Closed
eliperelman opened this issue Oct 15, 2018 · 6 comments
Assignees
Labels
Milestone

Comments

@eliperelman
Copy link
Member

With the Neutrino 9 beta, if you try overriding the template, you will get an exception:

module.exports = {
  options: {
    root: __dirname,
    mains: {
      index: {
        template: join(__dirname, "src/template.ejs"),
      },
    },
  },
  // ...
};
❯ yarn build
yarn run v1.10.1
$ webpack --mode production
/Users/eli/code/project/node_modules/webpack-cli/bin/cli.js:244
				throw err;
				^

TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received type undefined

If you re-specify the entry, it works as expected:

module.exports = {
  options: {
    root: __dirname,
    mains: {
      index: {
        entry: join(__dirname, "src/index.js"),
        template: join(__dirname, "src/template.ejs"),
      },
    },
  },
  // ...
};
@eliperelman eliperelman added this to the v9 milestone Oct 15, 2018
@edmorley
Copy link
Member

For a single entry-point project I would expect the html options to be set via html in the web preset options instead (since the mains options are meant as overrides). However I can see this still being an issue when eg multi-entrypoint and the first page wants a custom template but the others are using the global default via the html preset option.

@edmorley
Copy link
Member

@eliperelman what's the expected behaviour here? A more user-friendly error saying "must specify source" or special-casing index and merging the source value in there too? The former would also help the case where someone lists additional mains that are missing their source, whereas the latter would only help for index.

@eliperelman
Copy link
Member Author

My thought was the solution should be a merge of the existing value if its an object.

@edmorley
Copy link
Member

Would you mind taking this one?

@edmorley
Copy link
Member

@eliperelman do you know if you'll get a chance to look at this? :-)

@eliperelman
Copy link
Member Author

I'll see if I can look at it soon.

@eliperelman eliperelman self-assigned this Nov 20, 2018
@eliperelman eliperelman changed the title Cannot override entry entry template without also specifying the path to the entry again Cannot override main entry template without also specifying the path to the entry again Nov 26, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Development

No branches or pull requests

2 participants