{"size": 1599, "ext": "js", "max_stars_repo_path": "webpack.config.js", "max_stars_repo_name": "vitorcamachoo/webpack-settings", "max_stars_repo_stars_event_min_datetime": "2017-12-13T15:37:43.000Z", "max_stars_repo_stars_event_max_datetime": "2019-01-13T14:11:25.000Z", "max_issues_repo_path": "webpack.config.js", "max_issues_repo_name": "vitorcamachoo/webpack-settings", "max_issues_repo_issues_event_min_datetime": "2017-10-04T14:18:17.000Z", "max_issues_repo_issues_event_max_datetime": "2017-10-04T15:30:32.000Z", "max_forks_repo_path": "webpack.config.js", "max_forks_repo_name": "vitorcamachoo/webpack-settings", "max_forks_repo_forks_event_min_datetime": "2017-12-14T11:20:09.000Z", "max_forks_repo_forks_event_max_datetime": "2018-04-05T20:05:31.000Z"}
{"max_stars_count": 24, "max_issues_count": 2, "max_forks_count": 4, "avg_line_length": 23.1739130435, "max_line_length": 108, "alphanum_fraction": 0.492808005}
const path = require('path');

// plugins
const ExtractTextPlugin = require("extract-text-webpack-plugin");

// Helpers
const { paths, flags} = require('./utils');
const plugins = require('./webpack');

const { IS_DEV, IS_PROD, IS_WATCH } = flags;
const { BASE_DIR, DEV_DIR, DIST_DIR, PUBLIC_DIR, ENTRY_POINT } = paths;
const { common, development, production } = plugins;

module.exports = (env) => {

  return {
    cache: IS_DEV,
    watch: IS_WATCH,
    devtool: IS_DEV ? 'source-map' : false,
    entry: {
      app: [path.resolve(BASE_DIR, 'src/index')],
    },
  
    output: {
      path: DIST_DIR,
      publicPath: PUBLIC_DIR,
      filename: '[name].js',
    },
  
    module: {
      rules: [
        { test: /\.js$/, loader: 'babel-loader', exclude: /node_modules/, options: { "presets": ["env"] } },
        {
          test: /\.(css|scss)$/i,
          loader: ExtractTextPlugin.extract({
            use: [{
              loader: 'css-loader',
              options: {
                minimize: IS_PROD,
                sourceMap: IS_DEV,
              },
            }, {
              loader: 'sass-loader',
              options: {
                minimize: IS_PROD,
                sourceMap: IS_DEV,
              },
            }],
            fallback: 'style-loader',
          }),
        },
      ],
    },
  
    resolve: {
      extensions: ['.js', '.jsx', '.json', '.css'],
    },
  
    devServer: {
      contentBase: DIST_DIR,
      historyApiFallback: true,
    },
  
    plugins: IS_DEV ?
      [...common, ...development] :
      [...common, ...production],
  }
}
