const webpack = require('webpack');//to access built-in plugins
const path = require('path');

/*jshint -W117 */
const config = [
    { //игра
        mode: 'development', //production|development
        entry: './scripts/app.js', //входной файл
        context: path.resolve(__dirname),
        output: {
            path: path.resolve(__dirname, 'dist'),
            filename: 'bundle.js'
        },

        watch: true, //отслеживает изменения
        watchOptions: {
            aggregateTimeout: 100 //время до пересборки после внесения изменений
        },

        devtool: "eval",

        optimization: {
            splitChunks: {
                cacheGroups: {
                    commons: {
                        name: 'commons',
                        chunks: 'all',
                        minChunks: 2,
                        enforce: true
                    }
                }
            },
            minimize: true
        },

        plugins: [
            new webpack.ProvidePlugin({
                $: 'jquery',
                jQuery: 'jquery'
            })
        ]
    },

    { //редактор
        mode: 'development', //production|development
        entry: './scripts/editor/appEditor.js', //входной файл
        context: path.resolve(__dirname),
        output: {
            path: path.resolve(__dirname, 'dist_editor'),
            filename: 'bundle_editor.js'
        },

        watch: true,
        watchOptions: {
            aggregateTimeout: 100
        },
        devtool: "eval",

        optimization: {
            splitChunks: {
                cacheGroups: {
                    commons: {
                        name: 'commons',
                        chunks: 'all',
                        minChunks: 2,
                        enforce: true
                    }
                }
            }
        },

        plugins: [
            new webpack.ProvidePlugin({
                $: 'jquery',
                jQuery: 'jquery'
            })
        ]
    }
];
module.exports = config;
/*jshint +W117 */