The problem of webpack Multi-entry Packaging js Code

entry: {

pageA: "./src/pages/pageA.js",
pageB: "./src/pages/pageB.js",

},
above is my multi-entry configuration;

for example, if you have an a.js file,
when you package pageA, the final packaged js code is console.log ("A"), and
when you package pageB, the final packaged js code is console.log ("B"),

how can it be implemented?

problem to be solved: different js codes are packaged according to the different entry pages currently packaged, and the corresponding page (a.js) needs to determine which entry file is currently packaged.

Apr.07,2021

htmlwebpackplugin

Menu