// in next.config.js
module.exports = {
entry: "./entry",
};
// or
module.exports = {
entry: {
client: "./entry/client",
server: "./entry/server",
},
};
Here is a workaround for now:
Adding import "../entry/server.js";
in pages/_document.js
and adding the code below to next.config.js
.
module.exports = {
webpack: (config) => {
const entryFactory = config.entry;
config.entry = () => (
entryFactory()
.then((entry) => {
entry["main.js"] = [
"./entry/client.js",
...entry["main.js"],
];
return entry;
})
);
return config;
},
};
The above code makes a nested entry
array. Is that what's needed, or should there be a spread:
module.exports = {
webpack: (config) => {
const entryFactory = config.entry;
config.entry = () => (
entryFactory()
.then((entry) => {
entry["main.js"] = [
"./entry/client.js",
...entry["main.js"], // <-- Flatten the array?
];
return entry;
})
);
return config;
},
};
Yep @jcheroske your suggestion is correct.
I'll update the original code.
And I'm closing this issue.
Most helpful comment
Here is a workaround for now:
Adding
import "../entry/server.js";
inpages/_document.js
and adding the code below tonext.config.js
.