{"size": 1032, "ext": "js", "max_stars_repo_path": "gulp/tasks/webpack.js", "max_stars_repo_name": "ygoto3/hexo-theme-ygoto3", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "gulp/tasks/webpack.js", "max_issues_repo_name": "ygoto3/hexo-theme-ygoto3", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "gulp/tasks/webpack.js", "max_forks_repo_name": "ygoto3/hexo-theme-ygoto3", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 19.1111111111, "max_line_length": 60, "alphanum_fraction": 0.5368217054}
'use strict';

const gulp = require('gulp');
const gulpif = require('gulp-if');
const uglify = require('gulp-uglify');
const webpack = require('webpack-stream');

const config = require('../config');

const wpconf = merge => {
  let wpc = Object.assign(merge || {}, {
  
    output: {
      filename: config.js.output.filename,
      sourceMapFilename: config.js.output.sourceMapFilename,
      libraryTarget: 'umd'
    },
  
    resolve: {
      extensions: [ '', '.ts', '.js', '.css' ]
    },
  
    module: {
  
      loaders: [{
        test: /\.ts$/,
        loader: 'babel-loader!ts-loader'
      }, {
        test: /\.js$/,
        loader: 'babel-loader',
        query: {
          cacheDirectory: true
        }
      }]
  
    }
  
  });

  if (!config.production) {
    wpc.devtool = "#source-map";
    wpc.debug = true;
  }

  return wpc;
};

gulp.task('webpack', () => {
  gulp.src(config.js.src)
  .pipe( webpack( wpconf() ) )
  .pipe( gulpif( config.production, uglify() ) )
  .pipe( gulp.dest(config.js.dest) );
});
