<commit_before>import gulp from 'gulp';
import gutil from 'gulp-util';
import notifier from 'node-notifier';
import { create as browserSyncCreate } from 'browser-sync';
import webpack from 'webpack';
import eslint from 'gulp-eslint';
import filter from 'gulp-filter';
import rename from 'gulp-rename';
import shell from 'gulp-shell';
import runSequence from 'run-sequence';
import assign from 'lodash.assign';

const browserSync = browserSyncCreate();

browserSync.use({
  plugin() {},
  hooks: {
    'client:js': '___browserSync___.socket.on("disconnect", window.close.bind(window));'
  }
});

const sharedWebpackConfig = {
  module: {
    loaders: [
      {
        test: /\.jsx?$/,
        exclude: /dist|public|node_modules/,
        loader: 'babel'
      }
    ]
  },
  resolve: {
    extensions: ['', '.js', '.jsx']
  },
  watch: false
};

const libWebpackConfig = assign({}, sharedWebpackConfig, {
  entry: './src/index.js',
  output: {
    path: './lib',
    filename: 'react-stonecutter.js',
    library: 'reactStonecutter',
    libraryTarget: 'umd'
  },
  externals: {
    'react': 'react',
    'react-dom': 'react-dom',
    'react-addons-transition-group': 'react-addons-transition-group',
    'react-motion': 'react-motion',
    'enquire.js': 'enquire.js',
    'lodash.isequal': 'lodash.isequal',
    'lodash.partition': 'lodash.partition'
  }
});

const demoWebpackConfig = assign({}, sharedWebpackConfig, {
  entry: './demo/src/main.js',
  output: {
    path: './demo/public',
    filename: 'demo.js'
  }
});

// var devCompiler = webpack([
//   assign({}, libWebpackConfig, { devtool: 'inline-source-map' }),
//   assign({}, demoWebpackConfig, { devtool: 'inline-source-map' })
// ]);

const devCompiler = webpack([libWebpackConfig, demoWebpackConfig]);

gulp.task('webpack', done => {
  let firstTime = true;

  devCompiler.watch({
    aggregateTimeout: 100
  }, (err, stats) => {
    if (err) {
      notifier.notify({ title: 'Webpack Error', message: err });
      throw new gutil.PluginError('webpack', err);<commit_msg>Exclude correct externals<commit_after>import gulp from 'gulp';
import gutil from 'gulp-util';
import notifier from 'node-notifier';
import { create as browserSyncCreate } from 'browser-sync';
import webpack from 'webpack';
import eslint from 'gulp-eslint';
import filter from 'gulp-filter';
import rename from 'gulp-rename';
import shell from 'gulp-shell';
import runSequence from 'run-sequence';
import assign from 'lodash.assign';
import packageJson from './package.json';

const browserSync = browserSyncCreate();

browserSync.use({
  plugin() {},
  hooks: {
    'client:js': '___browserSync___.socket.on("disconnect", window.close.bind(window));'
  }
});

const sharedWebpackConfig = {
  module: {
    loaders: [
      {
        test: /\.jsx?$/,
        exclude: /dist|public|node_modules/,
        loader: 'babel'
      }
    ]
  },
  resolve: {
    extensions: ['', '.js', '.jsx']
  },
  watch: false
};

const libWebpackConfig = assign({}, sharedWebpackConfig, {
  entry: './src/index.js',
  output: {
    path: './lib',
    filename: 'react-stonecutter.js',
    library: 'reactStonecutter',
    libraryTarget: 'umd'
  },
  externals: [
    ...Object.keys(packageJson.dependencies),
    ...Object.keys(packageJson.peerDependencies)
  ].reduce((acc, val) => {
    acc[val] = val;
    return acc;
  }, {})
});

const demoWebpackConfig = assign({}, sharedWebpackConfig, {
  entry: './demo/src/main.js',
  output: {
    path: './demo/public',
    filename: 'demo.js'
  }
});

// var devCompiler = webpack([
//   assign({}, libWebpackConfig, { devtool: 'inline-source-map' }),
//   assign({}, demoWebpackConfig, { devtool: 'inline-source-map' })
// ]);

const devCompiler = webpack([libWebpackConfig, demoWebpackConfig]);

gulp.task('webpack', done => {
  let firstTime = true;

  devCompiler.watch({
    aggregateTimeout: 100
  }, (err, stats) => {
    if (err) {
      notifier.notify({ title: 'Webpack Error', message: err });
      throw new gutil.PluginError('webpack', err);
{'fraction_non_alphanumeric': 0.17255096966683242, 'fraction_numerical': 0.0014917951268025858, 'mean_word_length': 3.5664018161180477, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 8, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '760329', 'n_tokens_mistral': 1350, 'n_tokens_neox': 1332, 'n_words': 297}