{"size": 4124, "ext": "js", "max_stars_repo_path": "webpack.config.js", "max_stars_repo_name": "opsee/seadoo", "max_stars_repo_stars_event_min_datetime": "2021-03-17T08:34:53.000Z", "max_stars_repo_stars_event_max_datetime": "2021-03-17T08:34:53.000Z", "max_issues_repo_path": "webpack.config.js", "max_issues_repo_name": "opsee/seadoo", "max_issues_repo_issues_event_min_datetime": "2017-01-31T18:27:06.000Z", "max_issues_repo_issues_event_max_datetime": "2017-01-31T18:27:06.000Z", "max_forks_repo_path": "webpack.config.js", "max_forks_repo_name": "opsee/seadoo", "max_forks_repo_forks_event_min_datetime": "2017-01-31T18:26:12.000Z", "max_forks_repo_forks_event_max_datetime": "2017-01-31T18:26:12.000Z"}
{"max_stars_count": 1, "max_issues_count": 1, "max_forks_count": 1, "avg_line_length": 27.8648648649, "max_line_length": 173, "alphanum_fraction": 0.5957807953}
var webpack = require('webpack');
var ExtractTextPlugin = require('extract-text-webpack-plugin');
var HtmlWebpackPlugin = require('html-webpack-plugin');
var fs = require('fs');
var _ = require('lodash');
var seedling = require('seedling');

var path = require('path');
var node_modules = path.resolve(__dirname, 'node_modules');
var emissaryDir = path.resolve(__dirname, 'node_modules/emissary');
var graphiqlDir = path.resolve(__dirname, 'node_modules/graphiql');
var srcDir = path.join(__dirname, '/src');
var configDir = path.join(__dirname, '/config');

var definePlugin = new webpack.DefinePlugin({
  'process.env': {
    NODE_ENV: JSON.stringify(process.env.NODE_ENV),
    REVISION: JSON.stringify(fs.readFileSync('/dev/stdin').toString())
  }
});

var commonsPlugin = new webpack.optimize.CommonsChunkPlugin('vendor', 'vendor.bundle.js');

var vendors = ['lodash', 'react', 'moment', 'newforms', 'react-bootstrap', 'immutable', 'q', 'react-router', 'superagent', 'fuzzy', 'react-document-title', 'react-timeago'];

var uglify = new webpack.optimize.UglifyJsPlugin({
  mangle: true,
  compress: {
    warnings: false
  }
});

var config = {
  cache:true,
  context: srcDir,
  eslint:{
    configFile: `${node_modules}/opsee-style/.eslintrc`
  },
  entry: {
    'index': [
      'babel-polyfill',
      './js/index.jsx'
    ],
    vendor:vendors
  },
  output: {
    path: path.join(__dirname, "dist"),
    publicPath: "/",
    filename: "bundle.js",
    chunkFilename: "[name]-[id].[hash].js"
  },
  postcss: function(webpack){
    return [
      require('postcss-import')({
        addDependencyTo: webpack
      }),
      require('postcss-cssnext')({
        browsers: 'last 1 version, > 10%',
        features: {
          customProperties: {
            variables: seedling.flat
          }
        }
      }),
      require('postcss-url')()
    ];
  },
  module: {
    preLoaders:[
      {
        test: /\.js$|\.jsx$/, 
        loaders: ['eslint-loader'],
        exclude: [node_modules]
      },
    ],
    loaders: [
      {
        test: /\.js$|\.jsx$/,
        loader: 'babel-loader',
        query: {
          plugins: ['transform-runtime'],
          presets: ['es2015', 'react']
        },
        include: [srcDir, configDir, emissaryDir]
      },
      {
        test: /\.css$/,
        loader: 'style-loader!css-loader?module&localIdentName=[path][name]-[local]!postcss',
        exclude: [graphiqlDir]
      },
      {
        test: /\.css$/,
        loader: 'style-loader!css-loader!postcss',
        include: [graphiqlDir]
      },
      {
        test: /\.json$/,
        loaders: ['json']
      },
      {
        test: /\.(png|jpg|svg)$/,
        loader: 'url-loader?limit=8192',
        include: [srcDir, emissaryDir]
      }
    ]
  },
  noParse:vendors.map(v => `${node_modules}/${v}`),
  resolve: {
    extensions: ['', '.jsx', '.js', '.json', '.svg', '.png', '.jpg'],
    modulesDirectories: ['node_modules', 'src/js']
  },
  plugins: [
    new webpack.optimize.OccurenceOrderPlugin(),
    new webpack.NoErrorsPlugin(),
    definePlugin,
    new HtmlWebpackPlugin({
      hash:false,
      template:'src/index.html',
      favicon: 'src/img/favicon/favicon.ico'
    }),
    commonsPlugin
  ]
};

if (process.env.NODE_ENV === 'production'){
  config.eslint.failOnWarning = true;
  config.plugins.push(uglify);
  config.plugins.push(new ExtractTextPlugin('style.css'));
  config.module.loaders = config.module.loaders.map(item => {
    if (_.isEqual(item.test, /\.css$/)){
      if (item.loader === 'style-loader!css-loader?module&localIdentName=[path][name]-[local]!postcss'){
        item.loader = ExtractTextPlugin.extract('style-loader', 'css-loader?module&localIdentName=[path][name]-[local]!postcss-loader');
      } else {
        item.loader = ExtractTextPlugin.extract('style-loader', 'css-loader!postcss-loader');
      }
    }
    return item;
  });
} else {
  config.module.loaders.splice(0, 0, {
    test: /\.js$|\.jsx$/,
    loaders: ['react-hot'],
    include: [srcDir]
  });
  config.plugins.splice(1, 0, new webpack.HotModuleReplacementPlugin());
}

module.exports = config;