var Encore = require('@symfony/webpack-encore');

const debug = !Encore.isProduction();

Encore
    .setPublicPath('/bundles/autoadmin')
    .setOutputPath('src/Resources/public')
    .setManifestKeyPrefix('/public')
    .addEntry('aa.admin.min', './assets/back/js/app.js')
    .addEntry('aa.min', './assets/front/js/app.js')
    .disableSingleRuntimeChunk()
    /*
     * FEATURE CONFIG
     * https://symfony.com/doc/current/frontend.html#adding-more-features
     */
    .cleanupOutputBeforeBuild()
    .enableBuildNotifications()
    .enableSourceMaps(debug)
    .enableVersioning(false)
    .copyFiles({
        from: './assets',
        to: '[path][name].[ext]',
        pattern: /\.(png|jpg|jpeg|gif)$/
    })
    .enableSassLoader()
    .autoProvidejQuery()
    // auto prefix
    .enablePostCssLoader()
    // js minification
    .configureTerserPlugin(() => {
        return {
            parallel: true,
            terserOptions: {
                output: {
                    // strip comments
                    comments: false,
                }
            },
            extractComments: false,// no License file extract
        }
    })
    .addAliases({
        'vue/dist/vue': Encore.isProduction() ? 'vue/dist/vue.min.js' : 'vue/dist/vue.js',
        'vue': Encore.isProduction() ? 'vue/dist/vue.min.js' : 'vue/dist/vue.js',
    })
;

module.exports = Encore.getWebpackConfig();
