So Im using 2.0.0-beta.17 and trying to extend webpack config in next.config.js by adding a new entry point.
// next.config.js
let merge = require('webpack-merge');
module.exports = {
webpack: (config, {dev}) => {
return merge(config, {
entry: { fooEntry: './bar' }
});
}
}
It seems like I'm not able to do so since config.entry is an async function. Is there a way for me to extend and add to config.entry?
You can just create a new function like:
module.exports = {
webpack (config) {
return merge(config, {
entry () {
return config.entry().then((entry) => {
return Object.assign({}, entry, { fooEntry: './bar' })
})
}
}
}
}
@nkzawa , I am trying to add an additional entry point as per your suggestion. But the code provided results in a maximum callstack error.
I got it:
module.exports = {
webpack: function (config) {
if (ANALYZE) {
config.plugins.push(new BundleAnalyzerPlugin({
analyzerMode: 'server',
analyzerPort: 8888,
openAnalyzer: true
}))
}
return Object.assign({}, config, { entry: function() {
return config.entry().then((entry) => {
return Object.assign({}, entry, { '../static/worker.js': './Worker'})
})
}})
}
}
This thread has been automatically locked because it has not had recent activity. Please open a new issue for related bugs and link to relevant comments in this thread.
Most helpful comment
You can just create a new function like: