text: const { join } = require("path");
  
  module.exports = (nextConfig = {}) => {
    return Object.assign({}, nextConfig, {
      webpack(config, options) {
        if (!options.defaultLoaders) {
          throw new Error(
            "This plugin is not compatible with Next.js versions below 5.0.0 https://err.sh/next-plugins/upgrade"
          );
        }
  
        if (!options.isServer) {
          config.resolve = config.resolve || {};
          config.resolve.alias = config.resolve.alias || {};
          config.resolve.alias.config = join(__dirname, "browser.js");
        }
  
        if (typeof nextConfig.webpack === "function") {
          return nextConfig.webpack(config, options);
        }
  
        return config;
      }
    });
  };
  