{"size": 2559, "ext": "js", "max_stars_repo_path": "webpack.prod.config.js", "max_stars_repo_name": "chisbug/react-router4-mobx", "max_stars_repo_stars_event_min_datetime": "2017-08-09T02:40:00.000Z", "max_stars_repo_stars_event_max_datetime": "2018-02-06T09:41:51.000Z", "max_issues_repo_path": "webpack.prod.config.js", "max_issues_repo_name": "chisbug/react-router4-mobx", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "webpack.prod.config.js", "max_forks_repo_name": "chisbug/react-router4-mobx", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": 2, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 24.6057692308, "max_line_length": 92, "alphanum_fraction": 0.5134818288}
/*
  webpack 生产环境配置
*/
const path = require('path');
const webpack = require('webpack');
const AssetsPlugin = require('assets-webpack-plugin');
const WebWebpackPlugin = require('web-webpack-plugin');
const { WebPlugin, AutoWebPlugin } = WebWebpackPlugin;
const ExtractTextPlugin = require('extract-text-webpack-plugin');

module.exports = {
  entry: {
    main: './index.js',
    vendor: ['react', 'react-dom', 'react-router', 'react-router-dom', 'mobx-react', 'mobx']
  },
  output: {
    path: path.resolve(__dirname, 'dist'),
    filename: '[name].[hash].js',
    publicPath: '',
    sourceMapFilename: '[file].map',
    chunkFilename: '[name]-[id].[chunkhash:8].bundle.js'
  },
  context: path.resolve(__dirname, 'src'),
  module: {
    rules: [
      {
        test: /\.(js|jsx)$/,
        use: [
          'babel-loader',
        ],
        exclude: /node_modules/
      },
      {
        test: /\.css$/,
        use: ExtractTextPlugin.extract({
          fallback: 'style-loader',
          use: 'css-loader'
        })
      },
      {
        test: /\.less$/,
        use: ExtractTextPlugin.extract({
          fallback: 'style-loader',
          use: [
            { 
              loader: 'css-loader', 
              options: { 
                importLoaders: 1,
                minimize: true
              } 
            },
            'less-loader'
          ]
        })
      },
      {
        test: /\.(png|jpe?g|gif|svg)(\?.*)?$/,
        use: [
          'url-loader?limit=10240&publicPath=static/&outputPath=static/'
        ]
      },
      {
        test: /\.(woff2?|eot|ttf|otf)(\?.*)?$/,
        use: [
          'url-loader?limit=10240&publicPath=static/&outputPath=static/'
        ]
      }
    ],
  },
  resolve: {
    extensions: ['.js', '.jsx'],
    alias: {
      Actions: path.resolve(__dirname, 'src/actions'),
      Static: path.resolve(__dirname, 'static')
    }
  },
  plugins: [
    new webpack.optimize.UglifyJsPlugin({
      beautify: false,
      comments: false,
      compress: {
        warnings: false,
        drop_console: true,
        collapse_vars: true,
        reduce_vars: true
      }
    }),
    new webpack.DefinePlugin({
      'process.env': { NODE_ENV: '"production"' }
    }),
    new webpack.optimize.CommonsChunkPlugin({
      name: 'vendor', 
      filename: 'vendor.js' 
    }),
    new AssetsPlugin(),
    new WebPlugin({
      filename: 'index.html',
      requires: ['vendor', 'main'],
      template: './src/index.html'
    }),
    /* 打包css */
    new ExtractTextPlugin('./style.css')
  ]
}