<commit_before>var path = require('path');
var webpack = require('webpack');

var isDev = (process.env.NODE_ENV === 'development');
// these values are required in the config.app.js file -- we can't use
// process.env with webpack, we have to create these magic constants
// individually.
var defineEnvPlugin = new webpack.DefinePlugin({
  __MOCK__: JSON.stringify(process.env.MOCK || null),
  __MOCK_PARAMS__: JSON.stringify(process.env.MOCK_PARAMS || null),
  __UPLOAD_API__: JSON.stringify(process.env.UPLOAD_API || null),
  __API_HOST__: JSON.stringify(process.env.API_HOST || null),
  __SHOW_ACCEPT_TERMS__: JSON.stringify(process.env.SHOW_ACCEPT_TERMS || null),
  __PASSWORD_MIN_LENGTH__: JSON.stringify(process.env.PASSWORD_MIN_LENGTH || null),
  __INVITE_KEY__: JSON.stringify(process.env.INVITE_KEY || null),
  __DEV__: isDev,
  __TEST__: false
});

var plugins = [ defineEnvPlugin ];
var appEntry = (process.env.MOCK === 'true') ? './app/main.mock.js' : './app/main.js';
var entryScripts = [ appEntry ];
var loaders = [
  {test: /node_modules\/tideline\/.*\.js$/, exclude: /tideline\/node_modules/, loader: 'babel-loader'},
  {test: /\.less$/, loader: 'style-loader!css-loader!autoprefixer-loader!less-loader'},
  {test: /\.gif$/, loader: 'url-loader?limit=100000&mimetype=image/gif'},
  {test: /\.jpg$/, loader: 'url-loader?limit=10000&mimetype=image/jpg'},
  {test: /\.png$/, loader: 'url-loader?limit=10000&mimetype=image/png'},
  {test: /\.svg$/, loader: 'url-loader?limit=10000&mimetype=image/svg+xml'},
  {test: /favicon\.ico$/, loader: 'file-loader?name=favicon.ico&limit=100000&mimetype=image/x-icon'},
  {test: /\.eot$/, loader: 'url-loader?limit=10000&mimetype=application/vnd.ms-fontobject'},
  {test: /\.woff$/, loader: 'url-loader?limit=10000&mimetype=application/font-woff'},
  {test: /\.ttf$/, loader: 'url-loader?limit=10000&mimetype=application/x-font-ttf'},
  {test: /\.json$/, loader: 'json-loader'}
];

if (isDev) {
  plugins.push(new webpack.HotModuleReplacementPlugin());
  entryScripts = [
    'webpack-dev-server/client?http://0.0.0.0:3000',
    'webpack/hot/only-dev-server',
    appEntry
  ];
  loaders.push({test: /\.js$/, exclude: /(node_modules)/, loaders: ['react-hot', 'babel-loader']});
} else {
  loaders.push({test: /\.js$/, exclude: /(node_modules)/, loaders: ['babel-loader']});
}

module.exports = {
  entry: entryScripts,
  output: {
    path: path.join(__dirname, '/dist'),
    filename: 'bundle.js'
  },
  module: {
    loaders: loaders
  },
  // tideline DEV env variable only needs to be true in tideline local dev
  plugins: plugins,
  // resolves tideline's embedded React dependencies
  resolve: { fallback: path.join(__dirname, 'node_modules') },
  resolveLoader: { fallback: path.join(__dirname, 'node_modules') },
  devServer: {
    historyApiFallback: true
  }
};
<commit_msg>Update webpack config so that HMR works correctly<commit_after>var path = require('path');
var webpack = require('webpack');

var isDev = (process.env.NODE_ENV === 'development');
// these values are required in the config.app.js file -- we can't use
// process.env with webpack, we have to create these magic constants
// individually.
var defineEnvPlugin = new webpack.DefinePlugin({
  __MOCK__: JSON.stringify(process.env.MOCK || null),
  __MOCK_PARAMS__: JSON.stringify(process.env.MOCK_PARAMS || null),
  __UPLOAD_API__: JSON.stringify(process.env.UPLOAD_API || null),
  __API_HOST__: JSON.stringify(process.env.API_HOST || null),
  __SHOW_ACCEPT_TERMS__: JSON.stringify(process.env.SHOW_ACCEPT_TERMS || null),
  __PASSWORD_MIN_LENGTH__: JSON.stringify(process.env.PASSWORD_MIN_LENGTH || null),
  __INVITE_KEY__: JSON.stringify(process.env.INVITE_KEY || null),
  __DEV__: isDev,
  __TEST__: false
});

var plugins = [ defineEnvPlugin ];
var appEntry = (process.env.MOCK === 'true') ? './app/main.mock.js' : './app/main.js';
var entryScripts = [ appEntry ];
var loaders = [
  {test: /node_modules\/tideline\/.*\.js$/, exclude: /tideline\/node_modules/, loader: 'babel-loader'},
  {test: /\.less$/, loader: 'style-loader!css-loader!autoprefixer-loader!less-loader'},
  {test: /\.gif$/, loader: 'url-loader?limit=100000&mimetype=image/gif'},
  {test: /\.jpg$/, loader: 'url-loader?limit=10000&mimetype=image/jpg'},
  {test: /\.png$/, loader: 'url-loader?limit=10000&mimetype=image/png'},
  {test: /\.svg$/, loader: 'url-loader?limit=10000&mimetype=image/svg+xml'},
  {test: /favicon\.ico$/, loader: 'file-loader?name=favicon.ico&limit=100000&mimetype=image/x-icon'},
  {test: /\.eot$/, loader: 'url-loader?limit=10000&mimetype=application/vnd.ms-fontobject'},
  {test: /\.woff$/, loader: 'url-loader?limit=10000&mimetype=application/font-woff'},
  {test: /\.ttf$/, loader: 'url-loader?limit=10000&mimetype=application/x-font-ttf'},
  {test: /\.json$/, loader: 'json-loader'}
];

var output = {
  path: path.join(__dirname, '/dist'),
  filename: 'bundle.js'
}

if (isDev) {
  output.publicPath = 'http://localhost:3000/';
  plugins.push(new webpack.HotModuleReplacementPlugin());
  entryScripts = [
    'webpack-dev-server/client?http://localhost:3000',
    'webpack/hot/only-dev-server',
    appEntry
  ];
  loaders.push({test: /\.js$/, exclude: /(node_modules)/, loaders: ['react-hot', 'babel-loader']});
} else {
  loaders.push({test: /\.js$/, exclude: /(node_modules)/, loaders: ['babel-loader']});
}

module.exports = {
  entry: entryScripts,
  output: output,
  module: {
    loaders: loaders
  },
  // tideline DEV env variable only needs to be true in tideline local dev
  plugins: plugins,
  // resolves tideline's embedded React dependencies
  resolve: { fallback: path.join(__dirname, 'node_modules') },
  resolveLoader: { fallback: path.join(__dirname, 'node_modules') },
  devServer: {
    publicPath: output.publicPath,
    hot: true,
    historyApiFallback: true
  }
};

{'fraction_non_alphanumeric': 0.18295825459543033, 'fraction_numerical': 0.017179178835251677, 'mean_word_length': 4.523719165085389, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, 'pii_count': 1, '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': '1309463', 'n_tokens_mistral': 2174, 'n_tokens_neox': 2054, 'n_words': 388}