<commit_before>const loaders = require('./loaders');
const path = require('path');
const VueLoaderPlugin = require('vue-loader/lib/plugin');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const WebpackAutoInject = require('webpack-auto-inject-version');
// const UglifyJsPlugin = require('uglifyjs-webpack-plugin');
const webpack = require('webpack');

const devBuild = process.env.NODE_ENV === 'dev';
console.log(`Starting webpack build with NODE_ENV: ${process.env.NODE_ENV}`);

const config = {
    entry: {
        main: [ path.resolve('./client/index.ts') ]
    },
    output: {
        publicPath: '/',
        // path: path.resolve('../../../build/resources/main/static/'),
        path: path.resolve('../resources/static/'),
        filename: '[name].js'
    },
    resolve: {
        extensions: [ '.ts', '.tsx', '.js', '.json', '.svg' ],
        modules: [ 'client', 'img', 'styles', 'node_modules' ]
    },
    mode: devBuild ? 'development' : 'production',
    // source-map doesn't seem to be working, see webpack bug reports
    devtool: devBuild ? 'cheap-eval-source-map' : undefined,//'source-map',
    plugins: [
        new VueLoaderPlugin(),
        new CopyWebpackPlugin([
            { from: 'img', to: 'img' }
        ]),
        new HtmlWebpackPlugin({
            template: './html/index.html',
            inject: 'body',
            hash: true
        }),
        new webpack.ProvidePlugin({
        }),
        // http://vuejs.github.io/vue-loader/en/workflow/production.html
        new webpack.DefinePlugin({
            'process.env': { // Short-circuits all vue.js warning code in "production" builds
                NODE_ENV: JSON.stringify(process.env.NODE_ENV)
            }
        }),
        new WebpackAutoInject({
            components: {
                AutoIncreaseVersion: false,
                InjectAsComment: false,
                InjectByTag: true
            },
            componentsOptions: {
                InjectByTag: {
                    fileRegex: /^.*\.js$/,
                    dateFormat: 'mmmm d, yyyy'
                }
            }
        })
    ],
    module: {
        rules: loaders
    }
};

// uglify builds an artifact that throws JS errors in Chrome and Firefox.  Disable for now.
// if (process.env.NODE_ENV === 'production') {
//     console.log('Running uglifyjs for production build');
//     config.plugins.push(
//         new UglifyJsPlugin({
//             uglifyOptions: {
//                 compress: {
//                     warnings: false
//                 }
//             },<commit_msg>Separate vendor stuff into separate bundle<commit_after>const loaders = require('./loaders');
const path = require('path');
const VueLoaderPlugin = require('vue-loader/lib/plugin');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const WebpackAutoInject = require('webpack-auto-inject-version');
// const UglifyJsPlugin = require('uglifyjs-webpack-plugin');
const webpack = require('webpack');

const devBuild = process.env.NODE_ENV === 'dev';
console.log(`Starting webpack build with NODE_ENV: ${process.env.NODE_ENV}`);

const config = {
    entry: {
        main: [ path.resolve('./client/index.ts') ]
    },
    output: {
        publicPath: '/',
        // path: path.resolve('../../../build/resources/main/static/'),
        path: path.resolve('../resources/static/'),
        filename: '[name].js'
    },
    resolve: {
        extensions: [ '.ts', '.tsx', '.js', '.json', '.svg' ],
        modules: [ 'client', 'img', 'styles', 'node_modules' ]
    },
    mode: devBuild ? 'development' : 'production',
    // source-map doesn't seem to be working, see webpack bug reports
    devtool: devBuild ? 'cheap-eval-source-map' : undefined,//'source-map',
    plugins: [
        new VueLoaderPlugin(),
        new CopyWebpackPlugin([
            { from: 'img', to: 'img' }
        ]),
        new HtmlWebpackPlugin({
            template: './html/index.html',
            inject: 'body',
            hash: true
        }),
        new webpack.ProvidePlugin({
        }),
        // http://vuejs.github.io/vue-loader/en/workflow/production.html
        new webpack.DefinePlugin({
            'process.env': { // Short-circuits all vue.js warning code in "production" builds
                NODE_ENV: JSON.stringify(process.env.NODE_ENV)
            }
        }),
        new WebpackAutoInject({
            components: {
                AutoIncreaseVersion: false,
                InjectAsComment: false,
                InjectByTag: true
            },
            componentsOptions: {
                InjectByTag: {
                    fileRegex: /^.*\.js$/,
                    dateFormat: 'mmmm d, yyyy'
                }
            }
        })
    ],
    module: {
        rules: loaders
    },

    optimization: {
        splitChunks: {
            cacheGroups: {
                // Create a separate chunk for everything in node_modules
                vendor: {
                    test: /node_modules/,
                    name: 'vendor',
                    enforce: true,
                    chunks: 'all'
                }
            }
        }
    }
};

// uglify builds an artifact that throws JS errors in Chrome and Firefox.  Disable for now.
// if (process.env.NODE_ENV === 'production') {
//     console.log('Running uglifyjs for production build');
//     config.plugins.push(
//         new UglifyJsPlugin({
//             uglifyOptions: {
//                 compress: {
//                     warnings: false
//                 }
//             },
{'fraction_non_alphanumeric': 0.14421385860007035, 'fraction_numerical': 0.0, 'mean_word_length': 1.7795698924731183, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, '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': '6950000', 'n_tokens_mistral': 1613, 'n_tokens_neox': 1572, 'n_words': 345}