{"size": 1685, "ext": "js", "max_stars_repo_path": "src/methods/getCssLoaders.js", "max_stars_repo_name": "TapasFE/tapas-build", "max_stars_repo_stars_event_min_datetime": "2016-01-20T08:24:10.000Z", "max_stars_repo_stars_event_max_datetime": "2016-04-11T03:24:12.000Z", "max_issues_repo_path": "src/methods/getCssLoaders.js", "max_issues_repo_name": "tsingchao/tapas-build", "max_issues_repo_issues_event_min_datetime": "2016-02-15T03:12:35.000Z", "max_issues_repo_issues_event_max_datetime": "2016-04-11T03:17:12.000Z", "max_forks_repo_path": "src/methods/getCssLoaders.js", "max_forks_repo_name": "tsingchao/tapas-build", "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": 32.4038461538, "max_line_length": 129, "alphanum_fraction": 0.6367952522}
import ExtractTextPlugin from 'extract-text-webpack-plugin';

export default ({ extractCss, cssModules }) => {
  // accept a boolean to decide css modules or not
  let cssLoaderLocal = 'css?modules&importLoaders=1&localIdentName=[name]__[local]___[hash:base64:5]!postcss?pack=default';
  let cssLoaderGlobal = 'css!postcss?pack=default';
  let lessLoaderLocal = 'css?modules&importLoaders=1&localIdentName=[name]__[local]___[hash:base64:5]!postcss?pack=default!less';
  let lessLoaderGlobal = 'css!postcss?pack=default!less';
  if (extractCss) {
    cssLoaderLocal = ExtractTextPlugin.extract('style', cssLoaderLocal);
    cssLoaderGlobal = ExtractTextPlugin.extract('style', cssLoaderGlobal);
    lessLoaderLocal = ExtractTextPlugin.extract('style', lessLoaderLocal);
    lessLoaderGlobal = ExtractTextPlugin.extract('style', lessLoaderGlobal);
  } else {
    cssLoaderLocal = 'style!' + cssLoaderLocal;
    cssLoaderGlobal = 'style!' + cssLoaderGlobal;
    lessLoaderLocal = 'style!' + lessLoaderLocal;
    lessLoaderGlobal = 'style!' + lessLoaderGlobal;
  }
  if (cssModules) {
    return [
      {
        test: /\.css$/,
        loader: cssLoaderLocal,
        exclude: /node_modules/
      }, {
        test: /\.css$/,
        loader: cssLoaderGlobal,
        include: /node_modules/
      }, {
        test: /\.less$/,
        loader: lessLoaderLocal,
        exclude: /node_modules/
      }, {
        test: /\.less$/,
        loader: lessLoaderGlobal,
        include: /node_modules/
      }
    ];
  } else {
    return [
      {
        test: /\.css$/,
        loader: cssLoaderGlobal
      }, {
        test: /\.less$/,
        loader: lessLoaderGlobal
      }
    ]
  }
}
