-
Notifications
You must be signed in to change notification settings - Fork 213
Add support for multiple entry-points #367
Comments
I like this idea, but I am concerned about the precedent for an inconsistent entry. At the least, this should probably be normalized into an object, but maybe we can do better with a more explicit API? neutrino.options.entries
.add('index.js')
.add('otherpage.js');
// Then entry consumers can always iterate over all the entries
neutrino.options.entries.forEach((entry) => {
neutrino.use(htmlTemplate, { pluginId: `html-${entry}` });
}); 🤔 |
Ah yes that sounds good too. I also forgot to mention one point - the reason why I hadn't suggested that people iterate |
You raise another point about the conflation of entry options and webpack entry points. How can we make this clearer, less confusing, more intuitive to users? Maybe we should consider renaming |
I say this so we can make it clear that to add two pages, you might do: module.exports = {
options: {
pages: [
'index.js',
'admin.js'
]
},
// but to set up a vendor bundle you still need to do:
use: (neutrino) => {
neutrino.config.module
.entry('vendor')
.add(/* ... */);
}
}; |
I think using the term "pages" is presumptuous of it being a web app, and doesn't apply to libraries or Node.js apps. |
@edmorley would you be interested in taking this one on for v8? |
@edmorley how did you manage to have hot reload work for the entry ? I can't get it with the following:
|
In #326 the ability to manually use multiple instances of certain types of middleware (including
neutrino-middleware-html-template
) was added, which helped reduce the boilerplate mentioned there.However configuring Neutrino to use multiple entry-points is still pretty painful, due to the number of other parts of the build that reference
neutrino.options.entry
.For example one has to:
index
entrypointhtml
plugin (fromneutrino-middleware-html-template
)chunks
option tohtml-webpack-plugin
correctly (ie: using the same hardcoded vendor/runtimes names as inneutrino-middleware-chunk
. These names have changed between Neutrino versions, so having to keep them in sync is a pain).neutrino-middleware-dev-server
(such as vianeutrino-preset-{react,web}
, remember to prependwebpack/hot/dev-server
(ifoptions.hot
) or elsewebpack-dev-server/client
to each entrypoint.neutrino-preset-react
, remember to prependreact-hot-loader/patch
to each entrypoint.neutrino-middleware-pwa
remember to append the relevant PWA script....plus account for any other customisations that third-party middleware might make.
This results in a lot of boilerplate, and increases the potential for it to get out of sync with Neutrino.
I was thinking perhaps the Neutrino API could be made to support
neutrino.options.entry
being either a string or an object, with the string case behaving as it does now, and the object being used like so:The middleware would then be made to iterate the entrypoints when making modifications. For example
neutrino-middleware-html-template
would act as it does now, except use plugin names ofhtml-index
,html-foo
etc, and also set thechunks
property correctly. Andneutrino-preset-react
would add the react hot loader to all entrypoints etc.One question would be whether all consumers of
neutrino.options.entry
would have to handle both forms, or whether internally the string shorthand form should get converted to the object form with just oneindex
key.Thoughts?
The text was updated successfully, but these errors were encountered: