{"size": 1234, "ext": "js", "max_stars_repo_path": "webpack.component.config.js", "max_stars_repo_name": "pearlbea/nutmeg-cli", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "webpack.component.config.js", "max_issues_repo_name": "pearlbea/nutmeg-cli", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "webpack.component.config.js", "max_forks_repo_name": "pearlbea/nutmeg-cli", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 23.2830188679, "max_line_length": 59, "alphanum_fraction": 0.5826580227}
const HtmlWebpackPlugin = require('html-webpack-plugin');
const path = require('path');
const UglifyJsPlugin = require('uglifyjs-webpack-plugin');
const webpack = require('webpack');

module.exports = function(env, argv) {
  const production = env.production;
  const tag = env.tag;
  const workingDir = env.workingDir;
  let entry = {
    [`${tag}.bundled`]: path.resolve('dist', `${tag}.js`),
    [`${tag}.min`]: path.resolve('dist', `${tag}.js`),
  };
  let plugins = [
    new UglifyJsPlugin({
      include: /\.min\.js$/,
      parallel: true,
      sourceMap: true,
      uglifyOptions: {
        ecma: 6,
      },
    }),
    new HtmlWebpackPlugin({
      filename: 'index.html',
      template: 'index.html',
      chunks: [`${tag}.bundled`],
    }),
    new webpack.NamedModulesPlugin(),
  ];

  if (!production) {
    plugins.push(new webpack.HotModuleReplacementPlugin());
  }

  return {
    context: workingDir,
    devServer: {
      contentBase: path.resolve(workingDir, '.'),
      hot: true,
    },
    devtool: 'source-map',
    entry: entry,
    output: {
      filename: '[name].js',
      path: path.resolve(workingDir, 'dist'),
    },
    plugins: plugins,
    resolve: {
      extensions: ['.js'],
    },
  }
}
