Reputation: 129
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"
},
...
Upvotes: 3
Views: 2156
Reputation: 9101
webpack-hot-middleware/client
uses a magic __resourceQuery
for the job:
if (__resourceQuery) {
var querystring = require('querystring');
var overrides = querystring.parse(__resourceQuery.slice(1));
setOverrides(overrides);
}
Here, overrides
gets the querystring as an object.
Upvotes: 1
Reputation: 10419
I would suggest to create an entry point for each page and require index.js
from there.
Cleaner and easily readable.
Upvotes: 0