module.exports = function (grunt) {
    const common = [
        // Top level (dist)
        ...(global.is_release ? [] : [
            { expand: true, cwd: 'scripts', src: ['CNAME'], dest: 'dist' },
        ]),
        { expand: true, cwd: 'src/root_files/_common', src: ['**'], dest: 'dist' },

        // This branch
        { expand: true, cwd: 'src/javascript/',    src: ['manifest.json'],       dest: global.dist },
        { expand: true, cwd: 'src/download/fonts', src: ['binary_symbols.woff'], dest: `${global.dist}/download/fonts/` },

        { expand: true, cwd: `${global.node_modules_paths.binary_style}/src/images/favicons`, src: ['favicon.ico'], dest: global.dist },

        // Serve pushwoosh SDKs
        { expand: true, cwd: 'src/javascript/_common/lib/pushwooshSDK/', src: ['**'], dest: global.dist },
    ];

    const config = {
        app: {
            files: [
                ...common,
                { expand: true, cwd:  'src/root_files/app', src: ['**'],        dest: 'dist' }, // top level
                { expand: true, cwd:  'src/root_files/app', src: ['index.html'], dest: global.dist },

                // app, static
                { expand: true, cwd: 'src/download/',                  src: ['**'],              dest: `${global.dist}/download/` },
                { expand: true, cwd: 'src/images/',                    src: ['**', '!app_2/**'], dest: `${global.dist}/images/` },
                { expand: true, cwd: 'src/javascript/_autogenerated/', src: ['*.js'],            dest: `${global.dist}/js/texts/` },

                // binary-style
                { expand: true, cwd: `${global.node_modules_paths.binary_style}/src/images/favicons`, src: ['**'], dest: `${global.dist}/images/favicons/` },
                { expand: true, cwd: `${global.node_modules_paths.binary_style}/src/images/logo`,     src: ['**'], dest: `${global.dist}/images/logo/` },
            ],
        },
        app_2: {
            files: [
                ...common,
                ...(global.section === 'app_2' ? [ // to prioritize the `app` root files when it's not only `app_2`
                    { expand: true, cwd:  'src/root_files/app_2', src: ['**'], dest: 'dist' }, // top level
                    { expand: true, cwd:  'src/root_files/app_2', src: ['index.html'], dest: global.dist },
                ] : []),
                { expand: true, cwd:  'src/root_files/app_2', src: ['index.html'], dest: global.dist_app_2 },

                // app_2
                { expand: true, cwd: 'src/images/app_2',                     src: ['**'],   dest: `${global.dist_app_2}/images/` },
                { expand: true, cwd: 'src/javascript/_autogenerated/app_2/', src: ['*.js'], dest: `${global.dist_app_2}/js/texts/` },

                // binary-style
                { expand: true, cwd: `${global.node_modules_paths.binary_style}/src/images/favicons`, src: ['**'], dest: `${global.dist_app_2}/images/favicons/` },

                // ChartIQ dependencies
                { expand: true, cwd: `${global.node_modules_paths.smartcharts}/dist/`, src: ['*.smartcharts.*'],  dest: `${global.dist_app_2}/js/smartcharts/` },
                { expand: true, cwd: `${global.node_modules_paths.smartcharts}/dist/`, src: ['smartcharts.css*'], dest: `${global.dist_app_2}/css/` },
            ],
        },
        get all() {
            return {
                files: [
                    ...this.app.files,
                    ...this.app_2.files,
                ],
            };
        },
    };

    return { [global.section]: config[global.section] };
};

@@ -978,25 +978,33 @@
 c: %5B'**'
-%5D
 , 
-      
+'!index.html'%5D,
  dest: '
@@ -1097,32 +1097,39 @@
  %5B'index.html'%5D,
+       
  dest: global.di

Exclude index.html from copying to root in case global.dist is not root