{"size": 2624, "ext": "js", "max_stars_repo_path": "webpack.config.js", "max_stars_repo_name": "retrixe/Area51", "max_stars_repo_stars_event_min_datetime": "2018-04-13T17:48:24.000Z", "max_stars_repo_stars_event_max_datetime": "2021-03-02T13:31:34.000Z", "max_issues_repo_path": "webpack.config.js", "max_issues_repo_name": "retrixe/Area51", "max_issues_repo_issues_event_min_datetime": "2017-09-24T03:29:03.000Z", "max_issues_repo_issues_event_max_datetime": "2020-11-15T16:33:51.000Z", "max_forks_repo_path": "webpack.config.js", "max_forks_repo_name": "retrixe/Area51", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": 2, "max_issues_count": 2, "max_forks_count": null, "avg_line_length": 29.4831460674, "max_line_length": 110, "alphanum_fraction": 0.6063262195}
const path = require('path')
const HtmlWebpackPlugin = require('html-webpack-plugin')
const { CleanWebpackPlugin } = require('clean-webpack-plugin')
const CompressionWebpackPlugin = require('compression-webpack-plugin')

const html = (head, body) => (`
<html lang="en">
<head>
  <meta charset="UTF-8">
  <!-- Use minimum-scale=1 to enable GPU rasterization -->
  <meta
    name='viewport'
    content='user-scalable=0, initial-scale=1, minimum-scale=1, width=device-width, height=device-height'
  />
  <title>Area51</title>
  <meta property='og:type' content='website' />
  <meta property='og:title' content='Area51' />
  <meta property='og:image' content='/icon.png' />
  <meta property='og:description' content='A secure file server for HTTP(S).' />
  <meta name='Description' content='A secure file server for HTTP(S).'} />
  <meta name='robots' content='noindex,nofollow' />
  <meta name='theme-color' content='#43d98e' />
  <link rel='icon' href='/icon.png' />
  <link rel='stylesheet' href='https://fonts.googleapis.com/css?family=Roboto:300,400,500,700&display=swap' />
  <style id="jss-server-side"></style>
  <script id="injected"></script>
  ${head}
</head>
<body>
  <div id="app"></div>
  ${body}
</body>
</html>
`)
const isDev = env => (
  (env && env.NODE_ENV === 'development') ||
  process.env.NODE_ENV === 'development'
)

module.exports = env => ({
  entry: './src/client/index.js',
  mode: isDev(env) ? 'development' : 'production',
  devtool: isDev(env) ? 'inline-source-map' : undefined,
  output: {
    filename: '[name].[contenthash].js',
    path: path.resolve(__dirname, 'dist')
  },
  module: {
    rules: [{
      test: /\.(c|m)?js$/,
      exclude: /(node_modules|bower_components)/,
      use: {
        loader: 'babel-loader',
        options: {
          presets: ['@babel/preset-react', ['@babel/preset-env', {
            corejs: 3,
            targets: 'defaults',
            useBuiltIns: 'usage'
          }]]
        }
      }
    }]
  },
  plugins: [
    new CleanWebpackPlugin(),
    new HtmlWebpackPlugin({
      inject: false,
      publicPath: '/',
      templateContent: ({ htmlWebpackPlugin: { tags } }) => html(tags.headTags, tags.bodyTags)
    }),
    new CompressionWebpackPlugin(),
    new CompressionWebpackPlugin({ filename: '[path][base].br', algorithm: 'brotliCompress' })
  ],
  // Chunk splitting optimization.
  optimization: {
    moduleIds: 'deterministic',
    runtimeChunk: 'single',
    splitChunks: {
      cacheGroups: {
        vendor: {
          test: /[\\/]node_modules[\\/]/,
          name: 'vendors',
          chunks: 'all'
        }
      }
    }
  }
})
