<commit_before>'use strict';

const Path = require('path');
const Webpack = require('webpack');

const DEV_SERVER_PORT = 7000;
const NODE_ENV = process.env.NODE_ENV ? process.env.NODE_ENV.toLowerCase() : 'development';
const MODE_DEV_SERVER = process.argv[1].indexOf('webpack-dev-server') > -1 ? true : false;
const FAIL_ON_ERROR = process.env.FAIL_ON_ERROR ? JSON.parse(process.env.FAIL_ON_ERROR) : !MODE_DEV_SERVER; // disabled on dev-server mode, enabled in build mode
const OPTIMIZE = process.env.OPTIMIZE ? JSON.parse(process.env.OPTIMIZE) : NODE_ENV === 'production';

const plugins = [];

plugins.push(
	// Necessary for applying the correct environment everywhere
	new Webpack.DefinePlugin({
		'process.env': {
			'NODE_ENV': JSON.stringify(NODE_ENV)
		}
	})
);

if (!FAIL_ON_ERROR) {
	plugins.push(new Webpack.NoErrorsPlugin());
}

if (OPTIMIZE) {
	plugins.push(new Webpack.optimize.OccurrenceOrderPlugin());
	plugins.push(new Webpack.optimize.DedupePlugin());
	plugins.push(new Webpack.optimize.UglifyJsPlugin({
		compressor: {
			warnings: false
		}
	}));
}

const conf = {
	output: {
		path: Path.join(__dirname, 'public', 'assets'),
		filename: 'bundle.js',
		publicPath: '/assets/'
	},
	module: {
		loaders: [
			{
				test: /\.jsx?$/,
				loaders: ['babel'],
				exclude: /node_modules/
			}
		]
	},
	resolve: {
		extensions: ['', '.js', '.jsx']
	},
	plugins: plugins
};

// webpack-dev-server mode
if (MODE_DEV_SERVER) {
	plugins.push(new Webpack.HotModuleReplacementPlugin());
	conf.PORT = DEV_SERVER_PORT;
	conf.devtool = 'eval';
	conf.entry = [
		'babel-regenerator-runtime',
		'react-hot-loader/patch', // this has to be the first loaded plugin in order to work properly!
		'webpack-dev-server/client?http://0.0.0.0:' + DEV_SERVER_PORT, // WebpackDevServer host and port
		'webpack/hot/only-dev-server', // 'only' prevents reload on syntax errors
		'./src/app.jsx' // appʼs entry point
	];
} else {
	conf.devtool = 'source-map';
	conf.entry = ['babel-regenerator-runtime', './src/app.jsx'];
}

module.exports = conf;
<commit_msg>Use NamedModulesPlugin in development mode<commit_after>'use strict';

const Path = require('path');
const Webpack = require('webpack');

const DEV_SERVER_PORT = 7000;
const NODE_ENV = process.env.NODE_ENV ? process.env.NODE_ENV.toLowerCase() : 'development';
const MODE_DEV_SERVER = process.argv[1].indexOf('webpack-dev-server') > -1 ? true : false;
const FAIL_ON_ERROR = process.env.FAIL_ON_ERROR ? JSON.parse(process.env.FAIL_ON_ERROR) : !MODE_DEV_SERVER; // disabled on dev-server mode, enabled in build mode
const OPTIMIZE = process.env.OPTIMIZE ? JSON.parse(process.env.OPTIMIZE) : NODE_ENV === 'production';

const plugins = [
	// Necessary for applying the correct environment everywhere
	new Webpack.DefinePlugin({
		'process.env': {
			'NODE_ENV': JSON.stringify(NODE_ENV)
		}
	})
];

if (!FAIL_ON_ERROR) {
	plugins.push(new Webpack.NoErrorsPlugin());
}

if (OPTIMIZE) {
	plugins.push(new Webpack.optimize.OccurrenceOrderPlugin());
	plugins.push(new Webpack.optimize.DedupePlugin());
	plugins.push(new Webpack.optimize.UglifyJsPlugin({
		compressor: {
			warnings: false
		}
	}));
}

const conf = {
	output: {
		path: Path.join(__dirname, 'public', 'assets'),
		filename: 'bundle.js',
		publicPath: '/assets/'
	},
	module: {
		loaders: [
			{
				test: /\.jsx?$/,
				loaders: ['babel'],
				exclude: /node_modules/
			}
		]
	},
	resolve: {
		extensions: ['', '.js', '.jsx']
	},
	plugins: plugins
};

// webpack-dev-server mode
if (MODE_DEV_SERVER) {
	plugins.push(new Webpack.NamedModulesPlugin());
	plugins.push(new Webpack.HotModuleReplacementPlugin());
	conf.PORT = DEV_SERVER_PORT;
	conf.devtool = 'eval';
	conf.entry = [
		'babel-regenerator-runtime',
		'react-hot-loader/patch', // this has to be the first loaded plugin in order to work properly!
		'webpack-dev-server/client?http://0.0.0.0:' + DEV_SERVER_PORT, // WebpackDevServer host and port
		'webpack/hot/only-dev-server', // 'only' prevents reload on syntax errors
		'./src/app' // appʼs entry point
	];
} else {
	conf.devtool = 'source-map';
	conf.entry = ['babel-regenerator-runtime', './src/app'];
}

module.exports = conf;

{'fraction_non_alphanumeric': 0.16020236087689713, 'fraction_numerical': 0.00481811611659841, 'mean_word_length': 4.209535759096612, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, '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': '6673216', 'n_tokens_mistral': 1556, 'n_tokens_neox': 1455, 'n_words': 299}