webpack-chain
webpack-chain copied to clipboard
How to configure multiple pages?
config .entry('index') .add({ pageOne: './src/pageOne/index.js', pageTwo: './src/pageTwo/index.js', pageThree: './src/pageThree/index.js' }) .end()
This is error
Hi!
Multiple entrypoints and/or multi-main entries are defined like so:
config
.entry('index')
.add('src/index.js')
.end()
.entry('a-second-page')
.add('src/foo.js')
.add('src/bar.js')
.end();
.entry('a-third-page')
.add('src/baz.js');
If there's a way to make this clearer in the docs we'd more than gratefully accept a PR if you had a spare moment? :-)
@edmorley Thank you very much for your answer. My English is not very good, so there is nothing I can do to enhance the docs. I'm sorry.
Hi @edmorley I am wondering how to configure multi-main entries with different html template, could you guide me?
Very thankful.
@zen-li In Neutrino we do the following:
https://github.com/mozilla-neutrino/neutrino-dev/blob/5b78b4134489a667e72d366c7b4b3a3f357315e0/packages/web/index.js#L119-L134
The process here is to create an entry and an instance of html-webpack-plugin/template for every main entry you have.
['index', 'admin'].forEach(page => {
config.entry(page).add(`src/${page}`);
config.plugin(`html-${page}`).use(HtmlWebpackPlugin, [{
filename: `${page}.html`
}]);
});
Thanks @eliperelman , that was very helpful.
Actually, keeping open for docs.
For those wanna replace whole entry, can do:
const page = 'login'
config.entryPoints.clear()
config.entry(page).add(`src/${page}`)
@eliperelman what documentation would you like to write?