<commit_before>import webpack from 'webpack';
import path from 'path';
import HtmlWebpackPlugin from 'html-webpack-plugin';
import fs from 'fs';

const ROOT_PATH = path.resolve('.');
const { SSL_CERT, SSL_KEY } = process.env;

export default (env) => {
    const production = !!(env && env.prod);

    return {
        entry: {
            template: [
                'babel-polyfill',
                path.resolve(ROOT_PATH, 'examples', 'index')
            ]
        },
        resolve: {
            extensions: ['.js', '.jsx', '.scss']
        },
        output: {
            path: path.resolve(ROOT_PATH, 'build'),
                filename: '[name].bundle.js'
        },
        mode: (production ? 'production' : 'development'),
        devServer: {
            host: '0.0.0.0',
                disableHostCheck: true,
                port: 9009,
                historyApiFallback: true,
                compress: true,
                hot: true,
                https: !!(SSL_CERT && SSL_KEY),
                cert: SSL_CERT ? fs.readFileSync(path.join(__dirname, SSL_CERT)) : undefined,
                key: SSL_KEY ? fs.readFileSync(path.join(__dirname, SSL_KEY)) : undefined,
        },
        module: {
            rules: [
                {
                    test: /\.(js|jsx)$/,
                    use: ['babel-loader'],
                    exclude: path.resolve(ROOT_PATH, 'node_modules')
                },
                {
                    test: /\.scss$/,
                    use: [
                        {
                            loader: 'style-loader',
                            options: {
                                sourceMap: true
                            }
                        },
                        {
                            loader: 'css-loader',
                            options: {
                                sourceMap: true
                            }
                        },
                        {
                            loader: 'sass-loader',
                            options: {
                                sourceMap: true
                            }
                        }
                    ]
                }
            ]
        },
        devtool: 'inline-source-map',
            plugins: [
            new HtmlWebpackPlugin({
                template: path.resolve(ROOT_PATH, 'examples', 'index.html')
            }),
            new webpack.HotModuleReplacementPlugin(),
            new webpack.NamedModulesPlugin(),
            new webpack.NoEmitOnErrorsPlugin(),
            new webpack.DefinePlugin({
                'process.env.NODE_ENV': JSON.stringify(production ? 'production' : 'development'),
                __DEV__: !production,
                __QA__: false,
                __LIVE__: production,
            })
        ]
    };
};<commit_msg>:sparkles: Use HTTPS if SSL cert is available<commit_after>import webpack from 'webpack';
import path from 'path';
import HtmlWebpackPlugin from 'html-webpack-plugin';
import fs from 'fs';

const ROOT_PATH = path.resolve('.');

let sslCert;
let sslKey;
try {
    sslCert = fs.readFileSync(path.join(__dirname, 'ssl', 'ssl.crt'));
    sslKey = fs.readFileSync(path.join(__dirname, 'ssl', 'ssl.key'));
} catch (err) {
    sslCert = null;
    sslKey = null;
}

export default (env) => {
    const production = !!(env && env.prod);

    return {
        entry: {
            template: [
                'babel-polyfill',
                path.resolve(ROOT_PATH, 'examples', 'index')
            ]
        },
        resolve: {
            extensions: ['.js', '.jsx', '.scss']
        },
        output: {
            path: path.resolve(ROOT_PATH, 'build'),
            filename: '[name].bundle.js'
        },
        mode: (production ? 'production' : 'development'),
        devServer: {
            host: '0.0.0.0',
            disableHostCheck: true,
            port: 9009,
            historyApiFallback: true,
            compress: true,
            hot: true,
            https: !!(sslCert && sslKey),
            cert: sslCert,
            key: sslKey,
        },
        module: {
            rules: [
                {
                    test: /\.(js|jsx)$/,
                    use: ['babel-loader'],
                    exclude: path.resolve(ROOT_PATH, 'node_modules')
                },
                {
                    test: /\.scss$/,
                    use: [
                        {
                            loader: 'style-loader',
                            options: {
                                sourceMap: true
                            }
                        },
                        {
                            loader: 'css-loader',
                            options: {
                                sourceMap: true
                            }
                        },
                        {
                            loader: 'sass-loader',
                            options: {
                                sourceMap: true
                            }
                        }
                    ]
                }
            ]
        },
        devtool: 'inline-source-map',
        plugins: [
            new HtmlWebpackPlugin({
                template: path.resolve(ROOT_PATH, 'examples', 'index.html')
            }),
            new webpack.HotModuleReplacementPlugin(),
            new webpack.NamedModulesPlugin(),
            new webpack.NoEmitOnErrorsPlugin(),
            new webpack.DefinePlugin({
                'process.env.NODE_ENV': JSON.stringify(production ? 'production' : 'development'),
                __DEV__: !production,
                __QA__: false,
                __LIVE__: production,
            })
        ]
    };
};
{'fraction_non_alphanumeric': 0.1117260463507437, 'fraction_numerical': 0.002767208578346593, 'mean_word_length': 0.9791238877481178, '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': '74786', 'n_tokens_mistral': 1492, 'n_tokens_neox': 1403, 'n_words': 280}