<commit_before>const glob = require('glob');
const {join} = require('path');
const webpack = require('webpack');
const Copy = require('copy-webpack-plugin');
const HTML = require('html-webpack-plugin');
const Clean = require('clean-webpack-plugin');
const OfflinePlugin = require('offline-plugin');
const PurifyCSSPlugin = require('purifycss-webpack');
const Dashboard = require('webpack-dashboard/plugin');
const SWPrecache = require('sw-precache-webpack-plugin');
const ExtractText = require('extract-text-webpack-plugin');
const CnameWebpackPlugin = require('cname-webpack-plugin');
const CriticalPlugin = require('webpack-plugin-critical').CriticalPlugin;
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
const CompressionPlugin = require("compression-webpack-plugin");
const StyleExtHtmlWebpackPlugin = require('style-ext-html-webpack-plugin');
var HtmlWebpackInlineSourcePlugin = require('html-webpack-inline-source-plugin');

const uglify = require('./uglify');
const babel = require('./babel');

const root = join(__dirname, '..');

module.exports = isProd => {
	// base plugins array
	const plugins = [
		new Clean(['dist'], {root}),
		new Copy([{context: 'src/static/',from: '**/*.*'}]),
		new webpack.optimize.CommonsChunkPlugin({name: 'vendor'}),
		new webpack.DefinePlugin({
			'process.env.NODE_ENV': JSON.stringify(isProd
				? 'production'
				: 'development')
		}),
		new HTML({
			minify:{
				collapseWhitespace:true
			},
			template: 'src/index.html',
			inlineSource: '.(js)$'
		}),
		new HtmlWebpackInlineSourcePlugin(),
		new webpack.LoaderOptionsPlugin({
			options: {
				babel,
				postcss: [require('autoprefixer')({browsers: ['last 3 version']})]
			}
		})
	];

	if (isProd) {
		babel.presets.push('babili');

		plugins.push(
			new webpack.LoaderOptionsPlugin({minimize: true, debug: false}),
			new webpack.optimize.UglifyJsPlugin(uglify),
			new ExtractText('styles.[hash].css'),
			new StyleExtHtmlWebpackPlugin(),
			new PurifyCSSPlugin({
				paths: glob.sync(join(__dirname, 'src/*.html')),
				moduleExtensions: ['.html', '.js'],
				verbose: true,
				minimize: true
		}),
		new OfflinePlugin({
				relativePaths: false,
				publicPath: '/',
				updateStrategy: 'all',
				safeToUseOptionalCaches: true,
				caches: 'all',
				ServiceWorker: {
					navigateFallbackURL: '/',
					events: true
				},
				AppCache: {
					FALLBACK: { '/': '/' }
				}
			}),
		new CnameWebpackPlugin({domain: 'www.vitormalencar.com'}));
	} else {
		// dev only
		plugins.push(
			new webpack.HotModuleReplacementPlugin(),
			new webpack.NamedModulesPlugin(),
			new Dashboard()
		);
	}

	return plugins;
};<commit_msg>rollback falback<commit_after>const glob = require('glob');
const {join} = require('path');
const webpack = require('webpack');
const Copy = require('copy-webpack-plugin');
const HTML = require('html-webpack-plugin');
const Clean = require('clean-webpack-plugin');
const OfflinePlugin = require('offline-plugin');
const PurifyCSSPlugin = require('purifycss-webpack');
const Dashboard = require('webpack-dashboard/plugin');
const SWPrecache = require('sw-precache-webpack-plugin');
const ExtractText = require('extract-text-webpack-plugin');
const CnameWebpackPlugin = require('cname-webpack-plugin');
const CriticalPlugin = require('webpack-plugin-critical').CriticalPlugin;
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
const CompressionPlugin = require("compression-webpack-plugin");
const StyleExtHtmlWebpackPlugin = require('style-ext-html-webpack-plugin');
var HtmlWebpackInlineSourcePlugin = require('html-webpack-inline-source-plugin');

const uglify = require('./uglify');
const babel = require('./babel');

const root = join(__dirname, '..');

module.exports = isProd => {
	// base plugins array
	const plugins = [
		new Clean(['dist'], {root}),
		new Copy([{context: 'src/static/',from: '**/*.*'}]),
		new webpack.optimize.CommonsChunkPlugin({name: 'vendor'}),
		new webpack.DefinePlugin({
			'process.env.NODE_ENV': JSON.stringify(isProd
				? 'production'
				: 'development')
		}),
		new HTML({
			minify:{
				collapseWhitespace:true
			},
			template: 'src/index.html',
			inlineSource: '.(js)$'
		}),
		new HtmlWebpackInlineSourcePlugin(),
		new webpack.LoaderOptionsPlugin({
			options: {
				babel,
				postcss: [require('autoprefixer')({browsers: ['last 3 version']})]
			}
		})
	];

	if (isProd) {
		babel.presets.push('babili');

		plugins.push(
			new webpack.LoaderOptionsPlugin({minimize: true, debug: false}),
			new webpack.optimize.UglifyJsPlugin(uglify),
			new ExtractText('styles.[hash].css'),
			new StyleExtHtmlWebpackPlugin(),
			new PurifyCSSPlugin({
				paths: glob.sync(join(__dirname, 'src/*.html')),
				moduleExtensions: ['.html', '.js'],
				verbose: true,
				minimize: true
		}),
		new OfflinePlugin({
				relativePaths: false,
				publicPath: '/',
				updateStrategy: 'all',
				safeToUseOptionalCaches: true,
				caches: 'all',
				ServiceWorker: {
					navigateFallbackURL: '/',
					events: true
				},
				AppCache: false
			}),
		new CnameWebpackPlugin({domain: 'www.vitormalencar.com'}));
	} else {
		// dev only
		plugins.push(
			new webpack.HotModuleReplacementPlugin(),
			new webpack.NamedModulesPlugin(),
			new Dashboard()
		);
	}

	return plugins;
};
{'fraction_non_alphanumeric': 0.16237549332832174, 'fraction_numerical': 0.0003758691975192633, 'mean_word_length': 4.631746031746032, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '1148878', 'n_tokens_mistral': 1920, 'n_tokens_neox': 1664, 'n_words': 321}