{"size": 931, "ext": "js", "max_stars_repo_path": "app/webpack.config.js", "max_stars_repo_name": "ibrahimjelliti/ibrahim-phobia-bundle", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "app/webpack.config.js", "max_issues_repo_name": "ibrahimjelliti/ibrahim-phobia-bundle", "max_issues_repo_issues_event_min_datetime": "2020-06-13T11:56:54.000Z", "max_issues_repo_issues_event_max_datetime": "2020-06-13T11:56:54.000Z", "max_forks_repo_path": "app/webpack.config.js", "max_forks_repo_name": "ijelliti/ibrahim-phobia-bundle", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": 1, "max_forks_count": null, "avg_line_length": 27.3823529412, "max_line_length": 85, "alphanum_fraction": 0.6444683136}
const path = require('path');
const TerserPlugin = require('terser-webpack-plugin');

function getWebpackConfiguration(indexPath, installPath, externals) {
  let webpackExternals = {};
  if (externals) {
    for (external of externals) {
      webpackExternals[external] = 'external';
    }
  }
  return {
    entry: { main: path.resolve('./', indexPath) },
    mode: 'production',
    output: {
      filename: 'bundle.js',
      path: path.resolve('./', installPath),
      pathinfo: false
    },
    optimization: {
      // Remove the runtime part of the bundle
      namedChunks: true,
      runtimeChunk: { name: 'runtime' },
      minimize: true,
      // Minify bundle
      minimizer: [new TerserPlugin()]
    },
    // use for missing peer dependencies
    // Maybe the missing module should be installed, as needed for the module to work
    externals: webpackExternals
  };
}

module.exports = getWebpackConfiguration;
