const pluginFactory = (configure) => (nextConfig = {}) => { return Object.assign({}, nextConfig, { webpack(config, options) { configure(config, options); if(typeof nextConfig.webpack === 'function') { return nextConfig.webpack(config, options); } return config; } }); } module.exports = pluginFactory;