Webpack. Pass parameters to entry point

Viewed 1848

I have a multi-page app. And I have configured multi-entry points with one js file. The reason for making this: these two pages have a lot of the same code. So far, I have already read about webpack-plugins and webpack configuration without any result.

Question: Can I pass some parameter to page1 entry point and page2 entry point in order to my index.js file will resolve what exactly it should do? Is it possible? And could anyone give advice on this issue?

...
entry: {
    page1: "./index.js",
    page2: "./index.js"
},
...
2 Answers

I would suggest to create an entry point for each page and require index.js from there.

Cleaner and easily readable.

Related