<commit_before>/* eslint-disable */

const path = require('path');
const webpack = require('webpack');
const lodash = require('lodash');
const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin');

// makeConfig creates a new configuration file based on the passed options.
module.exports = function makeConfig(grunt) {
    let appConfigPath = path.join(process.cwd(), 'superdesk.config.js');

    if (process.env.SUPERDESK_CONFIG) {
        appConfigPath = path.join(process.cwd(), process.env.SUPERDESK_CONFIG);
    }
    if (grunt.option('config')) {
        appConfigPath = path.join(process.cwd(), grunt.option('config'));
    }

    const sdConfig = lodash.defaultsDeep(require(appConfigPath)(grunt), getDefaults(grunt));

    // shouldExclude returns true if the path p should be excluded from loaders
    // such as 'babel' or 'eslint'. This is to avoid including node_modules into
    // these loaders, but not node modules that are superdesk apps.
    const shouldExclude = function(p) {
        // don't exclude anything outside node_modules
        if (p.indexOf('node_modules') === -1) {
            return false;
        }

        // include only 'superdesk-core' and valid modules inside node_modules
        const validModules = ['superdesk-core'].concat(sdConfig.apps);

        return !validModules.some((app) => p.indexOf(app) > -1);
    };

    return {
        entry: {
            app: 'app/scripts/index.js'
        },

        output: {
            path: path.join(process.cwd(), 'dist'),
            filename: '[name].bundle.js',
            chunkFilename: '[id].bundle.js'
        },

        plugins: [
            new webpack.ProvidePlugin({
                $: 'jquery',
                'window.$': 'jquery',
                jQuery: 'jquery',
                'window.jQuery': 'jquery',
                moment: 'moment',
            }),
            new webpack.DefinePlugin({
                __SUPERDESK_CONFIG__: JSON.stringify(sdConfig)
            }),

            // Using TS transpileOnly mode to speed up things and using this plugin
            // for type checking. https://github.com/Realytics/fork-ts-checker-webpack-plugin
            new ForkTsCheckerWebpackPlugin({
                async: false
            })
        ],

        resolve: {
            modules: [
                __dirname,
                path.join(__dirname, '/app'),
                path.join(__dirname, '/app/scripts'),
                path.join(__dirname, '/app/styles/sass'),
                path.join(__dirname, '/node_modules/superdesk-core/scripts'),
                path.join(__dirname, '/node_modules/superdesk-core/styles/sass'),
                path.join(__dirname, '/node_modules/superdesk-core'),
                'node_modules'
            ],
            alias: {
                // 'moment-timezone': 'moment-timezone/builds/moment-timezone-with-data-2010-2020',
                'rangy-saverestore': 'rangy/lib/rangy-selectionsaverestore',
                'angular-embedly': 'angular-embedly/em-minified/angular-embedly.min',
                'jquery-gridster': 'gridster/dist/jquery.gridster.min',
                'external-apps': path.join(process.cwd(), 'dist', 'app-importer.generated.js'),
                i18n: path.join(process.cwd(), 'dist', 'locale.generated.js'),
                // ensure that react is loaded only once (3rd party apps can load more...)
                react: path.resolve('./node_modules/react')

            },
            extensions: ['.js', '.jsx', '.ts', '.tsx'],
        },

        module: {
            rules: [
                {
                    test: /\.(ts|tsx|js|jsx)$/,
                    exclude: shouldExclude,
                    loader: 'ts-loader',
                    options: {
                        transpileOnly: true,
                    }
                },
                {
                    enforce: 'pre',
                    test: /\.(ts|tsx|js|jsx)$/,
                    loader: 'eslint-loader',
                    exclude: /node_modules/,
                    options: {
                        configFile: './.eslintrc.js',
                        ignorePath: './.eslintignore'
                    }
                },
                {
                    test: /\.html$/,<commit_msg>LBSD-2459 Jcrop error when trying to set an avatar for users The problem was that we have two versions of jquery running in the app. The first one that comes from sir-trevor editor and the second one which is newer version that is simply a dependency of superdesk-core and liveblog itself. The solution was just to map jquery within our app to point to the correct one. We should improve this in the future though so we only have one or none jquery dependency in the project<commit_after>/* eslint-disable */

const path = require('path');
const webpack = require('webpack');
const lodash = require('lodash');
const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin');

// makeConfig creates a new configuration file based on the passed options.
module.exports = function makeConfig(grunt) {
    let appConfigPath = path.join(process.cwd(), 'superdesk.config.js');

    if (process.env.SUPERDESK_CONFIG) {
        appConfigPath = path.join(process.cwd(), process.env.SUPERDESK_CONFIG);
    }
    if (grunt.option('config')) {
        appConfigPath = path.join(process.cwd(), grunt.option('config'));
    }

    const sdConfig = lodash.defaultsDeep(require(appConfigPath)(grunt), getDefaults(grunt));

    // shouldExclude returns true if the path p should be excluded from loaders
    // such as 'babel' or 'eslint'. This is to avoid including node_modules into
    // these loaders, but not node modules that are superdesk apps.
    const shouldExclude = function(p) {
        // don't exclude anything outside node_modules
        if (p.indexOf('node_modules') === -1) {
            return false;
        }

        // include only 'superdesk-core' and valid modules inside node_modules
        const validModules = ['superdesk-core'].concat(sdConfig.apps);

        return !validModules.some((app) => p.indexOf(app) > -1);
    };

    return {
        entry: {
            app: 'app/scripts/index.js'
        },

        output: {
            path: path.join(process.cwd(), 'dist'),
            filename: '[name].bundle.js',
            chunkFilename: '[id].bundle.js'
        },

        plugins: [
            new webpack.ProvidePlugin({
                $: 'jquery',
                'window.$': 'jquery',
                jQuery: 'jquery',
                'window.jQuery': 'jquery',
                moment: 'moment',
            }),
            new webpack.DefinePlugin({
                __SUPERDESK_CONFIG__: JSON.stringify(sdConfig)
            }),

            // Using TS transpileOnly mode to speed up things and using this plugin
            // for type checking. https://github.com/Realytics/fork-ts-checker-webpack-plugin
            new ForkTsCheckerWebpackPlugin({
                async: false
            })
        ],

        resolve: {
            modules: [
                __dirname,
                path.join(__dirname, '/app'),
                path.join(__dirname, '/app/scripts'),
                path.join(__dirname, '/app/styles/sass'),
                path.join(__dirname, '/node_modules/superdesk-core/scripts'),
                path.join(__dirname, '/node_modules/superdesk-core/styles/sass'),
                path.join(__dirname, '/node_modules/superdesk-core'),
                'node_modules'
            ],
            alias: {
                // 'moment-timezone': 'moment-timezone/builds/moment-timezone-with-data-2010-2020',
                'rangy-saverestore': 'rangy/lib/rangy-selectionsaverestore',
                'angular-embedly': 'angular-embedly/em-minified/angular-embedly.min',
                'jquery-gridster': 'gridster/dist/jquery.gridster.min',
                'external-apps': path.join(process.cwd(), 'dist', 'app-importer.generated.js'),
                i18n: path.join(process.cwd(), 'dist', 'locale.generated.js'),
                // ensure that react is loaded only once (3rd party apps can load more...)
                react: path.resolve('./node_modules/react'),
                jquery: path.resolve('./node_modules/jquery')

            },
            extensions: ['.js', '.jsx', '.ts', '.tsx'],
        },

        module: {
            rules: [
                {
                    test: /\.(ts|tsx|js|jsx)$/,
                    exclude: shouldExclude,
                    loader: 'ts-loader',
                    options: {
                        transpileOnly: true,
                    }
                },
                {
                    enforce: 'pre',
                    test: /\.(ts|tsx|js|jsx)$/,
                    loader: 'eslint-loader',
                    exclude: /node_modules/,
                    options: {
                        configFile: './.eslintrc.js',
                        ignorePath: './.eslintignore'
                    }
                },
                {
                    test: /\.html$/,
{'fraction_non_alphanumeric': 0.12574061882817644, 'fraction_numerical': 0.0032916392363396972, 'mean_word_length': 1.6628688285130002, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '5866360', 'n_tokens_mistral': 2553, 'n_tokens_neox': 2383, 'n_words': 557}