<commit_before>const path = require('path');
const webpack = require('webpack');
const ExtractTextPlugin = require("extract-text-webpack-plugin");
const extractCSS = new ExtractTextPlugin('stylesheets/[name].css');

module.exports = (isTest, isDebug) => {
    const entries = {
        main: './src/Main.tsx',
        server: './src/Server.tsx',
        vendor: ['es6-promise', 'react-router', 'ts-helpers']
    };
    const testEntries = Object.assign({
        test: './test/Main.ts',
        testConfiguration: './test/configuration/Configuration.ts',
    }, entries);

    const config = {
        entry: isTest ? testEntries : entries,
        output: {
            path: path.resolve(__dirname + '/dist'),
            publicPath: '/',
            filename: '[name].bundle.js'
        },
        devtool: 'source-map',
        resolve: {
            modules: [
                path.resolve(__dirname),
                path.resolve(__dirname, 'src'),
                path.resolve(__dirname, 'node_modules')
            ],
            extensions: ['.ts', '.tsx', '.js', '.css', '.less']
        },
        module: {
            rules: [
                {
                    test: /\.otf$/,
                    loader: 'url-loader?limit=100000'
                }, {
                    test: /\.css$/,
                    loader: extractCSS.extract([
                        'css-loader',
                        'postcss-loader'
                    ])
                }, {
                    test: /\.less$/,
                    loader: extractCSS.extract([
                        'css-loader',
                        'postcss-loader',
                        'less-loader'
                    ])
                }, {
                    test: /\.tsx?$/,
                    loader: 'ts-loader'
                }
            ]
        },
        plugins: [
            extractCSS
        ],
        // What information should be printed to the console
        stats: {
            colors: true,
            reasons: isDebug,
            hash: isDebug,
            version: isDebug,
            timings: true,
            chunks: isDebug,
            chunkModules: isDebug,
            cached: isDebug,
            cachedAssets: isDebug,
        },
    };

    if (isTest) {
        /**
         * Instruments TS source files for subsequent code coverage.
         * See https://github.com/deepsweet/istanbul-instrumenter-loader
         */
        config.module.rules.push({
            enforce: 'post',
            test: /\.tsx?$/,
            loader: 'istanbul-instrumenter-loader',
            query: {
                esModules: true
            },
            include: [
                path.resolve(__dirname, 'src')
            ]
        });
    } else {
        config.plugins.push(new webpack.optimize.CommonsChunkPlugin({
            name: 'vendor',
            filename: 'vendor.bundle.js'
        }));
    }

    if (!isDebug) { // Only for production<commit_msg>KCWA-213 Fixed issue with Java server side environment using CommonsChunkPlugin<commit_after>const path = require('path');
const webpack = require('webpack');
const ExtractTextPlugin = require("extract-text-webpack-plugin");
const extractCSS = new ExtractTextPlugin('stylesheets/[name].css');

module.exports = (isTest, isDebug) => {
    const entries = {
        main: './src/Main.tsx',
        server: './src/Server.tsx',
        vendor: ['es6-promise', 'react-router', 'ts-helpers']
    };
    const testEntries = Object.assign({
        test: './test/Main.ts',
        testConfiguration: './test/configuration/Configuration.ts',
    }, entries);

    const config = {
        entry: isTest ? testEntries : entries,
        output: {
            path: path.resolve(__dirname + '/dist'),
            publicPath: '/',
            filename: '[name].bundle.js'
        },
        devtool: 'source-map',
        resolve: {
            modules: [
                path.resolve(__dirname),
                path.resolve(__dirname, 'src'),
                path.resolve(__dirname, 'node_modules')
            ],
            extensions: ['.ts', '.tsx', '.js', '.css', '.less']
        },
        module: {
            rules: [
                {
                    test: /\.otf$/,
                    loader: 'url-loader?limit=100000'
                }, {
                    test: /\.css$/,
                    loader: extractCSS.extract([
                        'css-loader',
                        'postcss-loader'
                    ])
                }, {
                    test: /\.less$/,
                    loader: extractCSS.extract([
                        'css-loader',
                        'postcss-loader',
                        'less-loader'
                    ])
                }, {
                    test: /\.tsx?$/,
                    loader: 'ts-loader'
                }
            ]
        },
        plugins: [
            extractCSS
        ],
        // What information should be printed to the console
        stats: {
            colors: true,
            reasons: isDebug,
            hash: isDebug,
            version: isDebug,
            timings: true,
            chunks: isDebug,
            chunkModules: isDebug,
            cached: isDebug,
            cachedAssets: isDebug,
        },
    };

    if (isTest) {
        /**
         * Instruments TS source files for subsequent code coverage.
         * See https://github.com/deepsweet/istanbul-instrumenter-loader
         */
        config.module.rules.push({
            enforce: 'post',
            test: /\.tsx?$/,
            loader: 'istanbul-instrumenter-loader',
            query: {
                esModules: true
            },
            include: [
                path.resolve(__dirname, 'src')
            ]
        });
    } else {
        config.plugins.push(new webpack.optimize.CommonsChunkPlugin({
            name: 'vendor',
            filename: 'vendor.bundle.js',
            // with more entries, this ensures that no other module
            // goes into the vendor chunk
            minChunks: Infinity
        }));
    }

    if (!isDebug) { // Only for production
{'fraction_non_alphanumeric': 0.1273286894540742, 'fraction_numerical': 0.0027539283978616556, 'mean_word_length': 1.2057877813504823, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 2, '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': '5285805', 'n_tokens_mistral': 1626, 'n_tokens_neox': 1545, 'n_words': 326}