<commit_before>const path = require('path');
const argv = require('yargs').argv;
const packageJson = require('./package.json');
const webpack = require('webpack');
const TerserJSPlugin = require('terser-webpack-plugin');
const WrapperPlugin = require('wrapper-webpack-plugin');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const OptimizeCSSAssetsPlugin = require('optimize-css-assets-webpack-plugin');

const BANNER = `${packageJson.title} v${packageJson.version} | Copyright (c) 2016-present ${packageJson.author}`;

if (argv.prod) {
    process.env.NODE_ENV = 'production';
}
let PROD = process.env.NODE_ENV === 'production';

module.exports = {
    mode: PROD ? 'production' : 'development',
    devtool: PROD ? 'source-map' : 'inline-source-map',

    entry: './src/index.js',
    output: {
        path: path.resolve(__dirname, 'dist'),
        library: packageJson.libraryName,
        libraryExport: 'default',
        libraryTarget: 'umd',
        umdNamedDefine: true,
        filename: `js/${packageJson.name}.js`,
        globalObject: `typeof self !== 'undefined' ? self : this`
    },

    optimization: {
        minimizer: [
            new TerserJSPlugin({
                sourceMap: true
            }),
            new OptimizeCSSAssetsPlugin({
                cssProcessorOptions: {
                    map: {
                        inline: false
                    }
                }
            })
        ],
    },

    plugins: PROD ? [
        new webpack.BannerPlugin(BANNER),
        new WrapperPlugin({
            test: /\.css$/,
            footer: `/*# sourceMappingURL=${packageJson.name}.css.map */`
        }),
        new MiniCssExtractPlugin({
            filename: `css/${packageJson.name}.css`
        })
    ] : [
        new MiniCssExtractPlugin({
            filename: `css/${packageJson.name}.css`
        })
    ],
    module: {
        rules: [
            {
                test: /\.js$/,
                exclude: /(node_modules|bower_components)/,
                use: [
                    {
                        loader: 'babel-loader'
                    },
                    {
                        loader: 'string-replace-loader',
                        options: {
                            multiple: [
                                {
                                    search: '@{version}',
                                    replace: packageJson.version
                                },
                                {
                                    search: '\\n\\s+',
                                    replace: '',
                                    flags: 'g'
                                }
                            ]
                        }
                    }
                ]
            },
            {
                test: /\.(sa|sc|c)ss$/,
                use: [
                    MiniCssExtractPlugin.loader,
                    'css-loader',
                    'sass-loader'
                ],
            }
        ]
    },
    externals: {
        jquery: 'jQuery'
    },
    resolve: {
        modules: [path.resolve('./node_modules'), path.resolve('./src')],
        extensions: ['.json', '.js']
    }
};
<commit_msg>Fix issue related to jquery external<commit_after>const path = require('path');
const argv = require('yargs').argv;
const packageJson = require('./package.json');
const webpack = require('webpack');
const TerserJSPlugin = require('terser-webpack-plugin');
const WrapperPlugin = require('wrapper-webpack-plugin');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const OptimizeCSSAssetsPlugin = require('optimize-css-assets-webpack-plugin');

const BANNER = `${packageJson.title} v${packageJson.version} | Copyright (c) 2016-present ${packageJson.author}`;

if (argv.prod) {
    process.env.NODE_ENV = 'production';
}
let PROD = process.env.NODE_ENV === 'production';

module.exports = {
    mode: PROD ? 'production' : 'development',
    devtool: PROD ? 'source-map' : 'inline-source-map',

    entry: './src/index.js',
    output: {
        path: path.resolve(__dirname, 'dist'),
        library: packageJson.libraryName,
        libraryExport: 'default',
        libraryTarget: 'umd',
        umdNamedDefine: true,
        filename: `js/${packageJson.name}.js`,
        globalObject: `typeof self !== 'undefined' ? self : this`
    },

    optimization: {
        minimizer: [
            new TerserJSPlugin({
                sourceMap: true
            }),
            new OptimizeCSSAssetsPlugin({
                cssProcessorOptions: {
                    map: {
                        inline: false
                    }
                }
            })
        ],
    },

    plugins: PROD ? [
        new webpack.BannerPlugin(BANNER),
        new WrapperPlugin({
            test: /\.css$/,
            footer: `/*# sourceMappingURL=${packageJson.name}.css.map */`
        }),
        new MiniCssExtractPlugin({
            filename: `css/${packageJson.name}.css`
        })
    ] : [
        new MiniCssExtractPlugin({
            filename: `css/${packageJson.name}.css`
        })
    ],
    module: {
        rules: [
            {
                test: /\.js$/,
                exclude: /(node_modules|bower_components)/,
                use: [
                    {
                        loader: 'babel-loader'
                    },
                    {
                        loader: 'string-replace-loader',
                        options: {
                            multiple: [
                                {
                                    search: '@{version}',
                                    replace: packageJson.version
                                },
                                {
                                    search: '\\n\\s+',
                                    replace: '',
                                    flags: 'g'
                                }
                            ]
                        }
                    }
                ]
            },
            {
                test: /\.(sa|sc|c)ss$/,
                use: [
                    MiniCssExtractPlugin.loader,
                    'css-loader',
                    'sass-loader'
                ],
            }
        ]
    },
    externals: {
        jquery: {
            amd: 'jquery',
            root: '$',
            commonjs: 'jquery',
            commonjs2: 'jquery'
        }
    },
    resolve: {
        modules: [path.resolve('./node_modules'), path.resolve('./src')],
        extensions: ['.json', '.js']
    }
};
<|endoftext|>


<commit_before>/**
 * @license Copyright (c) 2003-2015, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or http://ckeditor.com/license
 */

CKEDITOR.editorConfig = function( config ) {
    // Define changes to default configuration here.
    // For complete reference see:
    // http://docs.ckeditor.com/#!/api/CKEDITOR.config

    // The toolbar groups arrangement, optimized for a single toolbar row.
    config.toolbarGroups = [
        { name: 'document', groups: [ 'mode', 'document', 'doctools' ] },
        { name: 'clipboard', groups: [ 'clipboard', 'undo' ] },
        { name: 'editing', groups: [ 'find', 'selection', 'spellchecker', 'editing' ] },
        { name: 'forms', groups: [ 'forms' ] },
        '/',
        { name: 'basicstyles', groups: [ 'basicstyles', 'cleanup' ] },
        { name: 'paragraph', groups: [ 'list', 'indent', 'blocks', 'align', 'bidi', 'paragraph' ] },
        { name: 'links', groups: [ 'links' ] },
        { name: 'insert', groups: [ 'insert' ] },
        '/',
        { name: 'styles', groups: [ 'styles' ] },
        { name: 'colors', groups: [ 'colors' ] },
        { name: 'tools', groups: [ 'tools' ] },
        { name: 'others', groups: [ 'others' ] },
        { name: 'about', groups: [ 'about' ] }
    ];

    // The default plugins included in the basic setup define some buttons that
    // are not needed in a basic editor. They are removed here.
    // config.removeButtons = 'Cut,Copy,Paste,Undo,Redo,Anchor,Underline,Strike,Subscript,Superscript';
    config.removeButtons = 'NewPage,Preview,Scayt,HiddenField,Form,Checkbox,Radio,TextField,Textarea,Select,Button,ImageButton,CreateDiv,Flash,Smiley,SpecialChar,PageBreak,Iframe,About,Templates,Save,Print';

    config.height = 500;

    config.extraPlugins = 'justify';

    config.allowedContent = true;

    // Dialog windows are also simplified.
    config.removeDialogTabs = 'link:advanced';
};

// CKEDITOR.editorConfig = function( config ) {
//     config.toolbarGroups = [
//         { name: 'document', groups: [ 'mode', 'document', 'doctools' ] },
//         { name: 'clipboard', groups: [ 'clipboard', 'undo' ] },
//         { name: 'editing', groups: [ 'find', 'selection', 'spellchecker', 'editing' ] },
//         { name: 'forms', groups: [ 'forms' ] },
//         '/',
//         { name: 'basicstyles', groups: [ 'basicstyles', 'cleanup' ] },
//         { name: 'paragraph', groups: [ 'list', 'indent', 'blocks', 'align', 'bidi', 'paragraph' ] },
//         { name: 'links', groups: [ 'links' ] },
//         { name: 'insert', groups: [ 'insert' ] },
//         '/',
//         { name: 'styles', groups: [ 'styles' ] },
//         { name: 'colors', groups: [ 'colors' ] },
//         { name: 'tools', groups: [ 'tools' ] },
//         { name: 'others', groups: [ 'others' ] },
//         { name: 'about', groups: [ 'about' ] }
//     ];

//     config.removeButtons = 'NewPage,Preview,Scayt,HiddenField,Form,Checkbox,Radio,TextField,Textarea,Select,Button,ImageButton,CreateDiv,Image,Flash,Smiley,SpecialChar,PageBreak,Iframe,About,Templates,Save,Print';
// };
<commit_msg>limpeza de bloco comentado no config.js no CKEditor (#888)<commit_after>/**
 * @license Copyright (c) 2003-2015, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or http://ckeditor.com/license
 */

CKEDITOR.editorConfig = function( config ) {
    // Define changes to default configuration here.
    // For complete reference see:
    // http://docs.ckeditor.com/#!/api/CKEDITOR.config

    // The toolbar groups arrangement, optimized for a single toolbar row.
    config.toolbarGroups = [
        { name: 'document', groups: [ 'mode', 'document', 'doctools' ] },
        { name: 'clipboard', groups: [ 'clipboard', 'undo' ] },
        { name: 'editing', groups: [ 'find', 'selection', 'spellchecker', 'editing' ] },
        { name: 'forms', groups: [ 'forms' ] },
        '/',
        { name: 'basicstyles', groups: [ 'basicstyles', 'cleanup' ] },
        { name: 'paragraph', groups: [ 'list', 'indent', 'blocks', 'align', 'bidi', 'paragraph' ] },
        { name: 'links', groups: [ 'links' ] },
        { name: 'insert', groups: [ 'insert' ] },
        '/',
        { name: 'styles', groups: [ 'styles' ] },
        { name: 'colors', groups: [ 'colors' ] },
        { name: 'tools', groups: [ 'tools' ] },
        { name: 'others', groups: [ 'others' ] },
        { name: 'about', groups: [ 'about' ] }
    ];

    config.removeButtons = 'NewPage,Preview,Scayt,HiddenField,Form,Checkbox,Radio,TextField,Textarea,Select,Button,ImageButton,CreateDiv,Flash,Smiley,SpecialChar,PageBreak,Iframe,About,Templates,Save,Print';

    config.height = 500;

    config.extraPlugins = 'justify';

    config.allowedContent = true;

    // Dialog windows are also simplified.
    config.removeDialogTabs = 'link:advanced';
};
<|endoftext|>


<commit_before>'use strict';

// Modules
var webpack = require('webpack');
var autoprefixer = require('autoprefixer');
var HtmlWebpackPlugin = require('html-webpack-plugin');
var ExtractTextPlugin = require('extract-text-webpack-plugin');
var CopyWebpackPlugin = require('copy-webpack-plugin');
var path = require('path');

var nodeModulesPath = path.resolve(__dirname, 'node_modules');

/**
 * Env
 * Get npm lifecycle event to identify the environment
 */
var ENV = process.env.npm_lifecycle_event;
var isTest = ENV === 'test' || ENV === 'test-watch';
var isProd = ENV === 'build';

module.exports = function makeWebpackConfig() {
    /**
     * Config
     * Reference: http://webpack.github.io/docs/configuration.html
     * This is the object where all configuration gets set
     */
    var config = {};

    /**
     * Entry
     * Reference: http://webpack.github.io/docs/configuration.html#entry
     * Should be an empty object if it's generating a test build
     * Karma will set this when it's a test build
     */
    config.entry = isTest ? {} : {
        app: './src/app/app.js'
    };

    /**
     * Output
     * Reference: http://webpack.github.io/docs/configuration.html#output
     * Should be an empty object if it's generating a test build
     * Karma will handle setting it up for you when it's a test build
     */
    config.output = isTest ? {} : {
        // Absolute output directory
        path: __dirname + '/dist',

        // Output path from the view of the page
        // Uses webpack-dev-server in development
        publicPath: isProd ? '/' : 'http://localhost:8080/',

        // Filename for entry points
        // Only adds hash in build mode
        filename: isProd ? '[name].[hash].js' : '[name].bundle.js',

        // Filename for non-entry points
        // Only adds hash in build mode
        chunkFilename: isProd ? '[name].[hash].js' : '[name].bundle.js'
    };

    /**
     * Devtool
     * Reference: http://webpack.github.io/docs/configuration.html#devtool
     * Type of sourcemap to use per build type
     */
    if (isTest) {
        config.devtool = 'inline-source-map';
    } else if (isProd) {
        config.devtool = 'source-map';
    } else {
        config.devtool = 'eval-source-map';
    }

    /**
     * Loaders
     * Reference: http://webpack.github.io/docs/configuration.html#module-loaders
     * List: http://webpack.github.io/docs/list-of-loaders.html
     * This handles most of the magic responsible for converting modules
     */

    // Initialize module
    config.module = {
        loaders: [{
                // JS LOADER
                // Reference: https://github.com/babel/babel-loader
                // Transpile .js files using babel-loader
                // Compiles ES6 and ES7 into ES5 code
                test: /\.js$/,
                loader: 'babel-loader',
                exclude: /node_modules/
            }, {
                // CSS LOADER
                // Reference: https://github.com/webpack/css-loader
                // Allow loading css through js
                //
                // Reference: https://github.com/postcss/postcss-loader
                // Postprocess your css with PostCSS plugins
                test: /\.css$/,
                // Reference: https://github.com/webpack/extract-text-webpack-plugin
                // Extract css files in production builds
                //
                // Reference: https://github.com/webpack/style-loader
                // Use style-loader in development.
                loader: isTest ? 'null' : ExtractTextPlugin.extract({
                    fallback: 'style-loader',
                    use: 'css-loader?sourceMap!postcss-loader'
                })
            }, {
                // ASSET LOADER
                // Reference: https://github.com/webpack/file-loader
                // Copy png, jpg, jpeg, gif, svg, woff, woff2, ttf, eot files to output
                // Rename the file using the asset hash
                // Pass along the updated reference to your code
                // You can add here any file extension you want to get copied to your output
                test: /\.(png|jpg|jpeg|gif|svg|woff|woff2|ttf|eot)$/,
                loader: 'file-loader'
            }, {
                // HTML LOADER
                // Reference: https://github.com/webpack/raw-loader
                // Allow loading html through js
                test: /\.html$/,
                loader: 'raw-loader'
            }, {
                // ts-loader: convert typescript (es6) to javascript (es6),
                // babel-loader: converts javascript (es6) to javascript (es5)
                'test': /\.ts?$/,
                'loaders': ['babel-loader', 'ts-loader'],
                'exclude': [/node_modules/]
            }
        ]
    };

    // ISPARTA LOADER
    // Reference: https://github.com/ColCh/isparta-instrumenter-loader
    // Instrument JS files with Isparta for subsequent code coverage reporting
    // Skips node_modules and files that end with .test.js
    if (isTest) {
        config.module.preLoaders.push({
            test: /\.js$/,
            exclude: [
                /node_modules/,
                /\.spec\.js$/
            ],
            loader: 'isparta-loader'
        })
    }

    /**
     * Plugins
     * Reference: http://webpack.github.io/docs/configuration.html#plugins
     * List: http://webpack.github.io/docs/list-of-plugins.html
     */
    config.plugins = [];

    // Skip rendering index.html in test mode
    if (!isTest) {
        // Reference: https://github.com/ampedandwired/html-webpack-plugin
        // Render index.html
        config.plugins.push(
                new HtmlWebpackPlugin({
                    template: './src/public/index.html',
                    inject: 'body'
                }),
                // Reference: https://github.com/webpack/extract-text-webpack-plugin
                // Extract css files
                // Disabled when in test mode or not in build mode
                new ExtractTextPlugin({
                    filename: '[name].[hash].css',
                    disable: !isProd
                }))
    }

    // Add build specific plugins
    if (isProd) {
        config.plugins.push(
                // Reference: http://webpack.github.io/docs/list-of-plugins.html#noerrorsplugin
                // Only emit files when there are no errors
                new webpack.NoErrorsPlugin(),
                // Reference: http://webpack.github.io/docs/list-of-plugins.html#uglifyjsplugin
                // Minify all javascript, switch loaders to minimizing mode
                new webpack.optimize.UglifyJsPlugin({
                    compress : {
                        warnings: true
                    }
                }),
                new webpack.LoaderOptionsPlugin({
                    minimize: true
                }),
                // Copy assets from the public folder
                // Reference: https://github.com/kevlened/copy-webpack-plugin
                new CopyWebpackPlugin([{
                        from: __dirname + '/src/public'
                    }])
                )
    }

    /**
     * Dev server configuration
     * Reference: http://webpack.github.io/docs/configuration.html#devserver
     * Reference: http://webpack.github.io/docs/webpack-dev-server.html
     */
    config.devServer = {
        contentBase: './src/public',
        stats: 'minimal'
    };

    config.resolve = {
        modules: [
            path.join(__dirname, 'src'),
            'node_modules'
        ],
        'extensions': ['.js', '.ts']
    };

    return config;
}();
<commit_msg>fixed deprecated plugin #5<commit_after>'use strict';

// Modules
var webpack = require('webpack');
var autoprefixer = require('autoprefixer');
var HtmlWebpackPlugin = require('html-webpack-plugin');
var ExtractTextPlugin = require('extract-text-webpack-plugin');
var CopyWebpackPlugin = require('copy-webpack-plugin');
var path = require('path');

var nodeModulesPath = path.resolve(__dirname, 'node_modules');

/**
 * Env
 * Get npm lifecycle event to identify the environment
 */
var ENV = process.env.npm_lifecycle_event;
var isTest = ENV === 'test' || ENV === 'test-watch';
var isProd = ENV === 'build';

module.exports = function makeWebpackConfig() {
    /**
     * Config
     * Reference: http://webpack.github.io/docs/configuration.html
     * This is the object where all configuration gets set
     */
    var config = {};

    /**
     * Entry
     * Reference: http://webpack.github.io/docs/configuration.html#entry
     * Should be an empty object if it's generating a test build
     * Karma will set this when it's a test build
     */
    config.entry = isTest ? {} : {
        app: './src/app/app.js'
    };

    /**
     * Output
     * Reference: http://webpack.github.io/docs/configuration.html#output
     * Should be an empty object if it's generating a test build
     * Karma will handle setting it up for you when it's a test build
     */
    config.output = isTest ? {} : {
        // Absolute output directory
        path: __dirname + '/dist',

        // Output path from the view of the page
        // Uses webpack-dev-server in development
        publicPath: isProd ? '/' : 'http://localhost:8080/',

        // Filename for entry points
        // Only adds hash in build mode
        filename: isProd ? '[name].[hash].js' : '[name].bundle.js',

        // Filename for non-entry points
        // Only adds hash in build mode
        chunkFilename: isProd ? '[name].[hash].js' : '[name].bundle.js'
    };

    /**
     * Devtool
     * Reference: http://webpack.github.io/docs/configuration.html#devtool
     * Type of sourcemap to use per build type
     */
    if (isTest) {
        config.devtool = 'inline-source-map';
    } else if (isProd) {
        config.devtool = 'source-map';
    } else {
        config.devtool = 'eval-source-map';
    }

    /**
     * Loaders
     * Reference: http://webpack.github.io/docs/configuration.html#module-loaders
     * List: http://webpack.github.io/docs/list-of-loaders.html
     * This handles most of the magic responsible for converting modules
     */

    // Initialize module
    config.module = {
        loaders: [{
                // JS LOADER
                // Reference: https://github.com/babel/babel-loader
                // Transpile .js files using babel-loader
                // Compiles ES6 and ES7 into ES5 code
                test: /\.js$/,
                loader: 'babel-loader',
                exclude: /node_modules/
            }, {
                // CSS LOADER
                // Reference: https://github.com/webpack/css-loader
                // Allow loading css through js
                //
                // Reference: https://github.com/postcss/postcss-loader
                // Postprocess your css with PostCSS plugins
                test: /\.css$/,
                // Reference: https://github.com/webpack/extract-text-webpack-plugin
                // Extract css files in production builds
                //
                // Reference: https://github.com/webpack/style-loader
                // Use style-loader in development.
                loader: isTest ? 'null' : ExtractTextPlugin.extract({
                    fallback: 'style-loader',
                    use: 'css-loader?sourceMap!postcss-loader'
                })
            }, {
                // ASSET LOADER
                // Reference: https://github.com/webpack/file-loader
                // Copy png, jpg, jpeg, gif, svg, woff, woff2, ttf, eot files to output
                // Rename the file using the asset hash
                // Pass along the updated reference to your code
                // You can add here any file extension you want to get copied to your output
                test: /\.(png|jpg|jpeg|gif|svg|woff|woff2|ttf|eot)$/,
                loader: 'file-loader'
            }, {
                // HTML LOADER
                // Reference: https://github.com/webpack/raw-loader
                // Allow loading html through js
                test: /\.html$/,
                loader: 'raw-loader'
            }, {
                // ts-loader: convert typescript (es6) to javascript (es6),
                // babel-loader: converts javascript (es6) to javascript (es5)
                'test': /\.ts?$/,
                'loaders': ['babel-loader', 'ts-loader'],
                'exclude': [/node_modules/]
            }
        ]
    };

    // ISPARTA LOADER
    // Reference: https://github.com/ColCh/isparta-instrumenter-loader
    // Instrument JS files with Isparta for subsequent code coverage reporting
    // Skips node_modules and files that end with .test.js
    if (isTest) {
        config.module.preLoaders.push({
            test: /\.js$/,
            exclude: [
                /node_modules/,
                /\.spec\.js$/
            ],
            loader: 'isparta-loader'
        })
    }

    /**
     * Plugins
     * Reference: http://webpack.github.io/docs/configuration.html#plugins
     * List: http://webpack.github.io/docs/list-of-plugins.html
     */
    config.plugins = [];

    // Skip rendering index.html in test mode
    if (!isTest) {
        // Reference: https://github.com/ampedandwired/html-webpack-plugin
        // Render index.html
        config.plugins.push(
                new HtmlWebpackPlugin({
                    template: './src/public/index.html',
                    inject: 'body'
                }),
                // Reference: https://github.com/webpack/extract-text-webpack-plugin
                // Extract css files
                // Disabled when in test mode or not in build mode
                new ExtractTextPlugin({
                    filename: '[name].[hash].css',
                    disable: !isProd
                }))
    }

    // Add build specific plugins
    if (isProd) {
        config.plugins.push(
                // Reference: http://webpack.github.io/docs/list-of-plugins.html#noerrorsplugin
                // Only emit files when there are no errors
                new webpack.NoEmitOnErrorsPlugin(),
                // Reference: http://webpack.github.io/docs/list-of-plugins.html#uglifyjsplugin
                // Minify all javascript, switch loaders to minimizing mode
                new webpack.optimize.UglifyJsPlugin({
                    compress : {
                        warnings: true
                    }
                }),
                new webpack.LoaderOptionsPlugin({
                    minimize: true
                }),
                // Copy assets from the public folder
                // Reference: https://github.com/kevlened/copy-webpack-plugin
                new CopyWebpackPlugin([{
                        from: __dirname + '/src/public'
                    }])
                )
    }

    /**
     * Dev server configuration
     * Reference: http://webpack.github.io/docs/configuration.html#devserver
     * Reference: http://webpack.github.io/docs/webpack-dev-server.html
     */
    config.devServer = {
        contentBase: './src/public',
        stats: 'minimal'
    };

    config.resolve = {
        modules: [
            path.join(__dirname, 'src'),
            'node_modules'
        ],
        'extensions': ['.js', '.ts']
    };

    return config;
}();
<|endoftext|>


<commit_before>var webpack = require("webpack");

module.exports = {
  // entry: "./src/app.js",
  // entry: {
  //   app: "./src/app.js",
  //   vendors: ["jquery","bootstrap"]
  // },

  // live reload
  entry: {
    app: ['webpack/hot/dev-server','./src/app.js'],
    vendors: ["jquery","bootstrap"]
  },
  // plugins: [
  //   new webpack.HotModuleReplacementPlugin()
  // ]

  output: {
    path: "./build",
    filename: "build.js"
  },
  plugins: [
    new webpack.ProvidePlugin({
      $: "jquery",
      jQuery: "jquery",
      "window.jQuery": "jquery",
      "root.jQuery": "jquery"
    }),
    new webpack.optimize.CommonsChunkPlugin("vendors", "vendor.bundle.js")
  ],
  // externals: {
  //       // require("jquery") is external and available
  //       //  on the global var jQuery
  //       "jquery": "jQuery"
  // },

  module: {
    loaders: [
      { test: /\.vue$/, loader: "vue-loader" },
      { test: /\.css$/, loader: "style-loader!css-loader" }, // use ! to chain loaders
      { test: /\.(png|jpg)$/, loader: 'url-loader?limit=8192' }, // inline base64 URLs for <=8k images, direct URLs for the rest
      { test: /\.ttf$/,    loader: "file?mimetype=application/octet-stream" },
      { test: /\.eot$/,    loader: "file" },
      { test: /\.svg$/,    loader: "file?mimetype=image/svg+xml" },
      { test: /\.woff$/, loader: "url-loader?limit=10000&mimetype=application/font-woff" },
      { test: /\.woff2$/, loader: "url-loader?limit=10000&mimetype=application/font-woff2" }
    ]
  },
  devtool: "#source-map"
}
<commit_msg>remove root.jquery<commit_after>var webpack = require("webpack");

module.exports = {
  // entry: "./src/app.js",
  // entry: {
  //   app: "./src/app.js",
  //   vendors: ["jquery","bootstrap"]
  // },

  // live reload
  entry: {
    app: ['webpack/hot/dev-server','./src/app.js'],
    vendors: ["jquery","bootstrap"]
  },
  // plugins: [
  //   new webpack.HotModuleReplacementPlugin()
  // ]

  output: {
    path: "./build",
    filename: "build.js"
  },
  plugins: [
    new webpack.ProvidePlugin({
      $: "jquery",
      jQuery: "jquery",
      "window.jQuery": "jquery"
    }),
    new webpack.optimize.CommonsChunkPlugin("vendors", "vendor.bundle.js")
  ],
  // externals: {
  //       // require("jquery") is external and available
  //       //  on the global var jQuery
  //       "jquery": "jQuery"
  // },

  module: {
    loaders: [
      { test: /\.vue$/, loader: "vue-loader" },
      { test: /\.css$/, loader: "style-loader!css-loader" }, // use ! to chain loaders
      { test: /\.(png|jpg)$/, loader: 'url-loader?limit=8192' }, // inline base64 URLs for <=8k images, direct URLs for the rest
      { test: /\.ttf$/,    loader: "file?mimetype=application/octet-stream" },
      { test: /\.eot$/,    loader: "file" },
      { test: /\.svg$/,    loader: "file?mimetype=image/svg+xml" },
      { test: /\.woff$/, loader: "url-loader?limit=10000&mimetype=application/font-woff" },
      { test: /\.woff2$/, loader: "url-loader?limit=10000&mimetype=application/font-woff2" }
    ]
  },
  devtool: "#source-map"
}
<|endoftext|>


<commit_before>var redback = require('redback'),
    assert = require('assert'),
    Structure = redback.Structure,
    Hash = redback.Hash,
    List = redback.List;

redback = redback.createClient();

//Flush the DB and close the Redis connection after 500ms
setTimeout(function () {
    redback.client.flushdb(function (err) {
        redback.client.quit();
    });
}, 500);

var hash = new Hash(null, 'hash'), list = new List(null, 'list'), structure = new Structure(null, 'structure');

module.exports = {

    'test structure prototypal inheritance': function() {
        assert.ok(typeof structure.ttl === 'function');

        //These methods are inherited from Structure
        assert.ok(typeof hash.ttl === 'function');
        assert.ok(typeof list.ttl === 'function');
    },

    'test modifying the base prototype': function () {
        assert.ok(typeof structure.foo === 'undefined');
        assert.ok(typeof list.foo === 'undefined');
        assert.ok(typeof list.foo === 'undefined');

        //All structures inherit from Structure
        Structure.prototype.foo = function() {
            return 'foo';
        };

        //..so all children will inherit its methods
        assert.equal('foo', hash.foo());
        assert.equal('foo', list.foo());
    },

    'test modifying a childs prototype': function () {
        assert.ok(typeof structure.bar === 'undefined');
        assert.ok(typeof list.bar === 'undefined');
        assert.ok(typeof hash.bar === 'undefined');

        //Adding to a structure's prototype should not affect other structures
        Hash.prototype.bar = function() {
            return 'bar';
        }

        assert.equal('bar', hash.bar());
        assert.ok(typeof structure.bar === 'undefined');
        assert.ok(typeof list.bar === 'undefined');
    },

    'test creating a structure with no key': function () {
        var structures = [
            'List','Hash','Set','SortedSet','CappedList','DensitySet',
            'Channel','KeyPair','SocialGraph'
        ];

        structures.forEach(function (structure) {
            assert.throws(function () {
                redback['create' + Structure]();
            });
        });

        //Cache doesn't require a key..
        redback.createCache();
    },

    'test adding a custom structure': function () {
        redback.addStructure('TestQueue', {
            init: function (is_fifo) {
                this.fifo = is_fifo;
            },
            add: function (value, callback) {
                this.client.lpush(this.key, value, callback);
            },
            next: function (callback) {
                var method = this.fifo ? 'rpop' : 'lpop';
                this.client[method](this.key, callback);
            }
        });

        var lifo = redback.createTestQueue('test_addstructure_lifo_queue');

        lifo.add('foo', function (err) {
            lifo.add('bar', function (err) {
                lifo.next(function (err, value) {
                    assert.equal('bar', value);
                    lifo.next(function (err, value) {
                        assert.equal('foo', value);
                        lifo.next(function (err, value) {
                            assert.equal(null, value);
                        });
                    });
                });
            });
        });

        var fifo = redback.createTestQueue('test_addstructure_fifo_queue', true);

        fifo.add('foo', function (err) {
            fifo.add('bar', function (err) {
                fifo.next(function (err, value) {
                    assert.equal('foo', value);
                    fifo.next(function (err, value) {
                        assert.equal('bar', value);
                        fifo.next(function (err, value) {
                            assert.equal(null, value);
                        });
                    });
                });
            });
        });
    }

}
<commit_msg>Test destroy<commit_after>var redback = require('redback'),
    assert = require('assert'),
    Structure = redback.Structure,
    Hash = redback.Hash,
    List = redback.List;

redback = redback.createClient();

//Flush the DB and close the Redis connection after 500ms
setTimeout(function () {
    redback.client.flushdb(function (err) {
        redback.client.quit();
    });
}, 500);

var hash = new Hash(null, 'hash'), list = new List(null, 'list'), structure = new Structure(null, 'structure');

module.exports = {

    'test structure prototypal inheritance': function() {
        assert.ok(typeof structure.ttl === 'function');

        //These methods are inherited from Structure
        assert.ok(typeof hash.ttl === 'function');
        assert.ok(typeof list.ttl === 'function');
    },

    'test modifying the base prototype': function () {
        assert.ok(typeof structure.foo === 'undefined');
        assert.ok(typeof list.foo === 'undefined');
        assert.ok(typeof list.foo === 'undefined');

        //All structures inherit from Structure
        Structure.prototype.foo = function() {
            return 'foo';
        };

        //..so all children will inherit its methods
        assert.equal('foo', hash.foo());
        assert.equal('foo', list.foo());
    },

    'test modifying a childs prototype': function () {
        assert.ok(typeof structure.bar === 'undefined');
        assert.ok(typeof list.bar === 'undefined');
        assert.ok(typeof hash.bar === 'undefined');

        //Adding to a structure's prototype should not affect other structures
        Hash.prototype.bar = function() {
            return 'bar';
        }

        assert.equal('bar', hash.bar());
        assert.ok(typeof structure.bar === 'undefined');
        assert.ok(typeof list.bar === 'undefined');
    },

    'test creating a structure with no key': function () {
        var structures = [
            'List','Hash','Set','SortedSet','CappedList','DensitySet',
            'Channel','KeyPair','SocialGraph'
        ];

        structures.forEach(function (structure) {
            assert.throws(function () {
                redback['create' + Structure]();
            });
        });

        //Cache doesn't require a key..
        redback.createCache();
    },

    'test adding a custom structure': function () {
        redback.addStructure('TestQueue', {
            init: function (is_fifo) {
                this.fifo = is_fifo;
            },
            add: function (value, callback) {
                this.client.lpush(this.key, value, callback);
            },
            next: function (callback) {
                var method = this.fifo ? 'rpop' : 'lpop';
                this.client[method](this.key, callback);
            }
        });

        var lifo = redback.createTestQueue('test_addstructure_lifo_queue');

        lifo.add('foo', function (err) {
            lifo.add('bar', function (err) {
                lifo.next(function (err, value) {
                    assert.equal('bar', value);
                    lifo.next(function (err, value) {
                        assert.equal('foo', value);
                        lifo.next(function (err, value) {
                            assert.equal(null, value);
                        });
                    });
                });
            });
        });

        var fifo = redback.createTestQueue('test_addstructure_fifo_queue', true);

        fifo.add('foo', function (err) {
            fifo.add('bar', function (err) {
                fifo.next(function (err, value) {
                    assert.equal('foo', value);
                    fifo.next(function (err, value) {
                        assert.equal('bar', value);
                        fifo.next(function (err, value) {
                            assert.equal(null, value);
                        });
                    });
                });
            });
        });
    },

    'test structure (bg)save and destroy': function () {
        var hash = redback.createHash('test_structure_destroy');

        redback.save(function (err) {
            assert.ok(!err);
        });
        redback.save(true, function (err) {
            assert.ok(!err);
        });

        hash.set('foo', 'bar', function (err) {
            hash.get('foo', function (err, value) {
                assert.equal('bar', value);
                hash.destroy(function (err) {
                    hash.get('foo', function (err, value) {
                        assert.equal(null, value);
                    });
                });
            });
        });
    }

}
<|endoftext|>


<commit_before>var webpack = require('webpack')
var HtmlWebpackPlugin = require('html-webpack-plugin')
var production = process.env.NODE_ENV === 'production'
var forhtml = process.env.NODE_ENV === 'html'

var plugins = []

if (production) {
	plugins = plugins.concat(
		new webpack.optimize.UglifyJsPlugin({
			mangle: true,
			compress: {
				warnings: false,
			}
		})
	)
}

plugins = plugins.concat(
     new HtmlWebpackPlugin({
         filename: 'index.html',
         template: './src/index.html',
         inject: 'head',
         hash: false,
         minify: production ? {
             removeComments: true,
             minifyCSS: true,
             collapseWhitespace: true
         } : {}
     })
)

module.exports = {

	entry: {
        build: forhtml ? './src/html.js' : './src/index.js'
    },

	output: {
        path: production ? 'dist' : '',
		filename: production ? '[name].[hash].js' : '[name].js'
	},

	devtool: production || forhtml ? false : 'source-map',

	module: {
		loaders: [
			{
				test: /\.js$/,
				exclude: /node_modules/,
				loader: 'babel'
			},
			{
				test: /\.scss$/,
                loader: production ? 'style!css!postcss!sass' : 'style!css?sourceMap!postcss!sass?sourceMap'
			},
            {
                test: /\.svg$/,
                loader: 'svg-inline'
            }
		]
	},

    babel: {
        presets: ['es2015']
    },

    postcss: [
        require('autoprefixer')
    ],

	plugins: plugins
}
<commit_msg>retab<commit_after>var webpack = require('webpack')
var HtmlWebpackPlugin = require('html-webpack-plugin')
var production = process.env.NODE_ENV === 'production'
var forhtml = process.env.NODE_ENV === 'html'

var plugins = []

if (production) {
    plugins = plugins.concat(
        new webpack.optimize.UglifyJsPlugin({
            mangle: true,
            compress: {
                warnings: false,
            }
        })
    )
}

plugins = plugins.concat(
     new HtmlWebpackPlugin({
         filename: 'index.html',
         template: './src/index.html',
         inject: 'head',
         hash: false,
         minify: production ? {
             removeComments: true,
             minifyCSS: true,
             collapseWhitespace: true
         } : {}
     })
)

module.exports = {

    entry: {
        build: forhtml ? './src/html.js' : './src/index.js'
    },

    output: {
        path: production ? 'dist' : '',
        filename: production ? '[name].[hash].js' : '[name].js'
    },

    devtool: production || forhtml ? false : 'source-map',

    module: {
        loaders: [
            {
                test: /\.js$/,
                exclude: /node_modules/,
                loader: 'babel'
            },
            {
                test: /\.scss$/,
                loader: production ? 'style!css!postcss!sass' : 'style!css?sourceMap!postcss!sass?sourceMap'
            },
            {
                test: /\.svg$/,
                loader: 'svg-inline'
            }
        ]
    },

    babel: {
        presets: ['es2015']
    },

    postcss: [
        require('autoprefixer')
    ],

    plugins: plugins
}
<|endoftext|>


<commit_before>// Cribbed from the ever prolific Konstantin Kaefer
// https://github.com/mapbox/tilelive-mapnik/blob/master/test/support/assert.js

var fs = require('fs');
var path = require('path');
var util = require('util');

var mapnik = require('@carto/mapnik');
var debug = require('debug')('windshaft:assert');

var assert = module.exports = exports = require('assert');

function cartodbIdFeatureReducer(byIdAcc, feature) {
    if (!feature.properties.hasOwnProperty('cartodb_id')) {
        throw new Error('Expected `cartodb_id` property not found in feature');
    }
    byIdAcc[feature.properties.cartodb_id] = feature;
    return byIdAcc;
}

function featureCollectionFilter(feature) {
    return feature.type === 'FeatureCollection';
}

function nonFeatureCollectionFilter(feature) {
    return !featureCollectionFilter(feature);
}

/**
 * Takes an image data as an input and an image path and compare them using Mapnik's Image.compare in case the
 * similarity is not within the tolerance limit it will callback with an error.
 *
 * @param buffer The image data to compare from
 * @param {string} referenceImageRelativeFilePath The relative file to compare against
 * @param {number} tolerance tolerated mean color distance, as a per mil (‰)
 * @param {function} callback Will call to home with null in case there is no error, otherwise with the error itself
 * @see FUZZY in http://www.imagemagick.org/script/command-line-options.php#metric
 */
assert.imageEqualsFile = function(buffer, referenceImageRelativeFilePath, tolerance, callback) {
    callback = callback || function(err) { assert.ifError(err); };

    var referenceImageFilePath = path.resolve(referenceImageRelativeFilePath);

    var testImage = mapnik.Image.fromBytes(buffer);
    var referenceImage = mapnik.Image.fromBytes(fs.readFileSync(referenceImageFilePath,  { encoding: null }));

    imagesAreSimilar(testImage, referenceImage, tolerance, function(err) {
        if (err) {
            var testImageFilePath = randomImagePath();
            testImage.save(testImageFilePath);
            debug("Images didn't match, test image is %s, expected is %s", testImageFilePath, referenceImageFilePath);
        }
        callback(err);
    });
};

assert.imageBuffersAreEqual = function(bufferA, bufferB, tolerance, persist, callback) {

    var imageA = mapnik.Image.fromBytes(bufferA);
    var imageB = mapnik.Image.fromBytes(bufferB);

    imagesAreSimilar(imageA, imageB, tolerance, function(err, similarity) {
        var imageFilePaths = [];
        if (persist) {
            var randStr = (Math.random() * 1e16).toString().substring(0, 8);
            var imageFilePathA = randomImagePath(randStr + '-a');
            var imageFilePathB = randomImagePath(randStr + '-b');
            imageA.save(imageFilePathA);
            imageB.save(imageFilePathB);

            imageFilePaths = [imageFilePathA, imageFilePathB];
        }
        callback(err, imageFilePaths, similarity);
    });
};

function randomImagePath(nameHint) {
    nameHint = nameHint || 'test';
    return path.resolve('test/results/png/image-' + nameHint + '-' + Date.now() + '.png');
}

function imagesAreSimilar(testImage, referenceImage, tolerance, callback) {
    if (testImage.width() !== referenceImage.width() || testImage.height() !== referenceImage.height()) {
        debug('Images are not the same size (width x height');
        return callback(new Error('Images are not the same size'));
    }

    var pixelsDifference = referenceImage.compare(testImage);
    var similarity = pixelsDifference / (referenceImage.width() * referenceImage.height());
    var tolerancePerMil = (tolerance / 1000);

    if (similarity > tolerancePerMil) {
        var err = new Error(
            util.format('Images are not similar (got %d similarity, expected %d)', similarity, tolerancePerMil)
        );
        err.similarity = similarity;
        callback(err, similarity);
    } else {
        callback(null, similarity);
    }
}

// images should have the same aspect ratio
assert.imagesAreSimilarIgnoreDimensions = function(testImage, referenceImage, tolerance, callback) {
    var biggestImage = null;
    var smallestImage = null;

    if (testImage.height() > referenceImage.height()) {
        biggestImage = testImage;
        smallestImage = referenceImage;
    } else if (testImage.height() < referenceImage.height()) {
        biggestImage = referenceImage;
        smallestImage = testImage;
    }

    if (biggestImage) {
        biggestImage.premultiplySync();
        // lanczos method has the best quality
        biggestImage.resize(smallestImage.width(), smallestImage.height(), {scaling_method: mapnik.imageScaling.lanczos}, function(err, biggestImage) {
            imagesAreSimilar(biggestImage, smallestImage, tolerance, callback);
        });
    } else {
        imagesAreSimilar(testImage, referenceImage, tolerance, callback);
    }

}

function Celldiff(x, y, ev, ov) {
    this.x = x;
    this.y = y;
    this.ev = ev;
    this.ov = ov;
}

Celldiff.prototype.toString = function() {
    return '(' + this.x + ',' + this.y + ')["' + this.ev + '" != "' + this.ov + '"]';
};

// @param tolerance number of tolerated grid cell differences
// jshint maxcomplexity:9
assert.utfgridEqualsFile = function(buffer, referenceFile, tolerance, callback) {
    //fs.writeFileSync('/tmp/grid.json', buffer, 'binary'); // <-- to debug/update
    var expected_json = JSON.parse(fs.readFileSync(referenceFile, 'utf8'));

      var obtained_json = Object.prototype.toString() === buffer.toString() ? buffer : JSON.parse(buffer);

      // compare grid
      var obtained_grid = obtained_json.grid;
      var expected_grid = expected_json.grid;
      var nrows = obtained_grid.length;
      if (nrows !== expected_grid.length) {
          return callback(
              new Error("Obtained grid rows (" + nrows + ") != expected grid rows (" + expected_grid.length + ")" )
          );
      }
      var celldiff = [];
      for (var i=0; i<nrows; ++i) {
        var ocols = obtained_grid[i];
        var ecols = expected_grid[i];
        var ncols = ocols.length;
        if ( ncols !== ecols.length ) {
            return callback(
                new Error("Obtained grid cols (" + ncols + ") != expected grid cols (" + ecols.length + ") on row " + i)
            );
        }
        for (var j=0; j<ncols; ++j) {
          var ocell = ocols[j];
          var ecell = ecols[j];
          if ( ocell !== ecell ) {
            celldiff.push(new Celldiff(i, j, ecell, ocell));
          }
        }
      }

      if ( celldiff.length > tolerance ) {
          return callback(new Error( celldiff.length + " cell differences: " + celldiff ));
      }

    try {
      assert.deepEqual(obtained_json.keys, expected_json.keys);
    } catch (e) {
        return callback(e);
    }

    return callback();
};
<commit_msg>Improve debug information for comparing fixture images<commit_after>// Cribbed from the ever prolific Konstantin Kaefer
// https://github.com/mapbox/tilelive-mapnik/blob/master/test/support/assert.js

var fs = require('fs');
var path = require('path');
var util = require('util');

var mapnik = require('@carto/mapnik');
var debug = require('debug')('windshaft:assert');

var assert = module.exports = exports = require('assert');

function cartodbIdFeatureReducer(byIdAcc, feature) {
    if (!feature.properties.hasOwnProperty('cartodb_id')) {
        throw new Error('Expected `cartodb_id` property not found in feature');
    }
    byIdAcc[feature.properties.cartodb_id] = feature;
    return byIdAcc;
}

function featureCollectionFilter(feature) {
    return feature.type === 'FeatureCollection';
}

function nonFeatureCollectionFilter(feature) {
    return !featureCollectionFilter(feature);
}

/**
 * Takes an image data as an input and an image path and compare them using Mapnik's Image.compare in case the
 * similarity is not within the tolerance limit it will callback with an error.
 *
 * @param buffer The image data to compare from
 * @param {string} referenceImageRelativeFilePath The relative file to compare against
 * @param {number} tolerance tolerated mean color distance, as a per mil (‰)
 * @param {function} callback Will call to home with null in case there is no error, otherwise with the error itself
 * @see FUZZY in http://www.imagemagick.org/script/command-line-options.php#metric
 */
assert.imageEqualsFile = function(buffer, referenceImageRelativeFilePath, tolerance, callback) {
    callback = callback || function(err) { assert.ifError(err); };

    var referenceImageFilePath = path.resolve(referenceImageRelativeFilePath);

    var testImage = mapnik.Image.fromBytes(buffer);
    var referenceImage = mapnik.Image.fromBytes(fs.readFileSync(referenceImageFilePath,  { encoding: null }));

    imagesAreSimilar(testImage, referenceImage, tolerance, function(err) {
        if (err) {
            var testImageFilePath = randomImagePath();
            testImage.save(testImageFilePath);
            debug(`Images didn't match. Test result: file://${testImageFilePath} Expected: file://${referenceImageFilePath}`);
            debug(`Create a GIF with: convert -delay 50 -loop 0 ${testImageFilePath} ${referenceImageFilePath} /tmp/diff.gif`);
        }
        callback(err);
    });
};

assert.imageBuffersAreEqual = function(bufferA, bufferB, tolerance, persist, callback) {

    var imageA = mapnik.Image.fromBytes(bufferA);
    var imageB = mapnik.Image.fromBytes(bufferB);

    imagesAreSimilar(imageA, imageB, tolerance, function(err, similarity) {
        var imageFilePaths = [];
        if (persist) {
            var randStr = (Math.random() * 1e16).toString().substring(0, 8);
            var imageFilePathA = randomImagePath(randStr + '-a');
            var imageFilePathB = randomImagePath(randStr + '-b');
            imageA.save(imageFilePathA);
            imageB.save(imageFilePathB);

            imageFilePaths = [imageFilePathA, imageFilePathB];
        }
        callback(err, imageFilePaths, similarity);
    });
};

function randomImagePath(nameHint) {
    nameHint = nameHint || 'test';
    return path.resolve('test/results/png/image-' + nameHint + '-' + Date.now() + '.png');
}

function imagesAreSimilar(testImage, referenceImage, tolerance, callback) {
    if (testImage.width() !== referenceImage.width() || testImage.height() !== referenceImage.height()) {
        debug('Images are not the same size (width x height');
        return callback(new Error('Images are not the same size'));
    }

    var pixelsDifference = referenceImage.compare(testImage);
    var similarity = pixelsDifference / (referenceImage.width() * referenceImage.height());
    var tolerancePerMil = (tolerance / 1000);

    if (similarity > tolerancePerMil) {
        var err = new Error(
            util.format('Images are not similar (got %d similarity, expected %d)', similarity, tolerancePerMil)
        );
        err.similarity = similarity;
        callback(err, similarity);
    } else {
        callback(null, similarity);
    }
}

// images should have the same aspect ratio
assert.imagesAreSimilarIgnoreDimensions = function(testImage, referenceImage, tolerance, callback) {
    var biggestImage = null;
    var smallestImage = null;

    if (testImage.height() > referenceImage.height()) {
        biggestImage = testImage;
        smallestImage = referenceImage;
    } else if (testImage.height() < referenceImage.height()) {
        biggestImage = referenceImage;
        smallestImage = testImage;
    }

    if (biggestImage) {
        biggestImage.premultiplySync();
        // lanczos method has the best quality
        biggestImage.resize(smallestImage.width(), smallestImage.height(), {scaling_method: mapnik.imageScaling.lanczos}, function(err, biggestImage) {
            imagesAreSimilar(biggestImage, smallestImage, tolerance, callback);
        });
    } else {
        imagesAreSimilar(testImage, referenceImage, tolerance, callback);
    }

}

function Celldiff(x, y, ev, ov) {
    this.x = x;
    this.y = y;
    this.ev = ev;
    this.ov = ov;
}

Celldiff.prototype.toString = function() {
    return '(' + this.x + ',' + this.y + ')["' + this.ev + '" != "' + this.ov + '"]';
};

// @param tolerance number of tolerated grid cell differences
// jshint maxcomplexity:9
assert.utfgridEqualsFile = function(buffer, referenceFile, tolerance, callback) {
    //fs.writeFileSync('/tmp/grid.json', buffer, 'binary'); // <-- to debug/update
    var expected_json = JSON.parse(fs.readFileSync(referenceFile, 'utf8'));

      var obtained_json = Object.prototype.toString() === buffer.toString() ? buffer : JSON.parse(buffer);

      // compare grid
      var obtained_grid = obtained_json.grid;
      var expected_grid = expected_json.grid;
      var nrows = obtained_grid.length;
      if (nrows !== expected_grid.length) {
          return callback(
              new Error("Obtained grid rows (" + nrows + ") != expected grid rows (" + expected_grid.length + ")" )
          );
      }
      var celldiff = [];
      for (var i=0; i<nrows; ++i) {
        var ocols = obtained_grid[i];
        var ecols = expected_grid[i];
        var ncols = ocols.length;
        if ( ncols !== ecols.length ) {
            return callback(
                new Error("Obtained grid cols (" + ncols + ") != expected grid cols (" + ecols.length + ") on row " + i)
            );
        }
        for (var j=0; j<ncols; ++j) {
          var ocell = ocols[j];
          var ecell = ecols[j];
          if ( ocell !== ecell ) {
            celldiff.push(new Celldiff(i, j, ecell, ocell));
          }
        }
      }

      if ( celldiff.length > tolerance ) {
          return callback(new Error( celldiff.length + " cell differences: " + celldiff ));
      }

    try {
      assert.deepEqual(obtained_json.keys, expected_json.keys);
    } catch (e) {
        return callback(e);
    }

    return callback();
};
<|endoftext|>


<commit_before>var path = require('path');
var webpack = require('webpack');

var entry = ['./app/js/index.js'];

if (process.env.NODE_ENV === 'development') {
  entry = entry.concat([
    'webpack-dev-server/client?http://localhost:3000',
    'webpack/hot/only-dev-server',
  ]);
}

module.exports = {
  devtool: 'eval',
  entry: entry,
  output: {
    path: path.join(__dirname, 'demos'),
    filename: 'bundle.js',
    publicPath: '/app/js/',
  },
  plugins: [
    new webpack.HotModuleReplacementPlugin(),
    new webpack.NoErrorsPlugin(),
  ],
  resolve: {
    extensions: ['', '.js', '.jsx'],
  },
  module: {
    loaders: [{
      test: /\.jsx?$/,
      loaders: ['react-hot', 'babel'],
      exclude: /build|lib|node_modules/,
    }],
  },
};
<commit_msg>Delete webpack.config.js<commit_after><|endoftext|>


<commit_before>/* eslint-disable no-var */
var path = require('path')
var webpack = require('webpack')
var Clean = require('clean-webpack-plugin')

var webpackConfig = require('./webpack-base-config')
webpackConfig.entry = path.resolve(__dirname, 'src/main.js')

if (process.env.npm_lifecycle_event === 'release') {
  webpackConfig.plugins.push(new webpack.optimize.UglifyJsPlugin({
    compress: {warnings: false},
    output: {comments: false}
  }))
} else {
  webpackConfig.plugins.push(new Clean(['dist'], {verbose: false}))
}

webpackConfig.output = {
  path: path.resolve(__dirname, 'dist'),
  publicPath: '<%=baseUrl%>/',
  filename: 'clappr.js',
  library: ['clappr', 'Clappr'],
  libraryTarget: 'umd'
}

module.exports = webpackConfig
<commit_msg>Revert "Export with UMD as 'clappr' and 'Clappr'"<commit_after>/* eslint-disable no-var */
var path = require('path')
var webpack = require('webpack')
var Clean = require('clean-webpack-plugin')

var webpackConfig = require('./webpack-base-config')
webpackConfig.entry = path.resolve(__dirname, 'src/main.js')

if (process.env.npm_lifecycle_event === 'release') {
  webpackConfig.plugins.push(new webpack.optimize.UglifyJsPlugin({
    compress: {warnings: false},
    output: {comments: false}
  }))
} else {
  webpackConfig.plugins.push(new Clean(['dist'], {verbose: false}))
}

webpackConfig.output = {
  path: path.resolve(__dirname, 'dist'),
  publicPath: '<%=baseUrl%>/',
  filename: 'clappr.js',
  library: 'Clappr',
  libraryTarget: 'umd'
}

module.exports = webpackConfig
<|endoftext|>


<commit_before>const path = require('path')
const webpack = require('webpack')
const merge = require('webpack-merge')

module.exports = merge(require('./webpack.base'), {
  context: __dirname,

  entry: {
    'index': './src/index.js',
    'index.min': './src/index.js'
  },

  output: {
    path: path.resolve(__dirname, 'dist'),
    filename: '[name].js',
    library: 'vue-table-component',
    libraryTarget: 'umd'
  },

  externals: [
    'moment', 'vue'
  ],

  plugins: [
    new webpack.optimize.UglifyJsPlugin({
      include: /\.min\.js$/,
      minimize: true
    })
  ]
})
<commit_msg>Minor change<commit_after>const path = require('path')
const webpack = require('webpack')
const merge = require('webpack-merge')

module.exports = merge(require('./webpack.base'), {
  context: __dirname,

  entry: {
    'index': './src/index.js',
    'index.min': './src/index.js'
  },

  output: {
    path: path.resolve(__dirname, 'dist'),
    filename: '[name].js',
    library: 'vue-flex-datatable',
    libraryTarget: 'umd'
  },

  externals: [
    'moment', 'vue'
  ],

  plugins: [
    new webpack.optimize.UglifyJsPlugin({
      include: /\.min\.js$/,
      minimize: true
    })
  ]
})
<|endoftext|>


<commit_before>var path = require('path');
var webpack = require('webpack');
var HtmlWebpackPlugin = require('html-webpack-plugin');
var ExtractTextPlugin = require('extract-text-webpack-plugin');

/**
 * Env
 * Get npm lifecycle event to identify the environment
 */
var ENV = process.env.npm_lifecycle_event;
var isTestWatch = ENV === 'test-watch';
var isTest = ENV === 'test' || isTestWatch;
// var isProd = ENV === 'build'; not using it right now //

module.exports = function makeWebpackConfig() {

	var config = {};

	config.devtool = isTest ? 'inline-source-map' : 'eval-source-map';

	if (!isTest) {
		config.entry = isTest ? {} : {
			'polyfills': './src/polyfills.ts',
			'vendor': './src/vendor.ts',
			'app': './src/main.ts'
		};
	}

	config.output = isTest ? {} : {
		path: root('dist'),
		publicPath: 'http://localhost:8080/',
		filename: 'js/[name].js',
		chunkFilename: '[id].chunk.js'
	};

	config.resolve = {
		extensions: ['.ts', '.js', '.json', '.css', '.less', '.html']
	};

	config.module = {
		rules: [
			{
				test: /\.ts$/,
				loaders: [
					{
						loader: 'awesome-typescript-loader'
					},
					'awesome-typescript-loader'
				],
				exclude: [isTest ? /\.(e2e)\.ts$/ : /\.(spec|e2e)\.ts$/, /node_modules\/(?!(ng2-.+))/]
			},
			{
				test: /\.ts$/,
				enforce: 'pre',
				loader: 'tslint-loader'
			},
			{
				test: /\.(png|jpe?g|gif|svg|otf|woff|woff2|ttf|eot|ico)(\?v=[0-9]\.[0-9]\.[0-9])?$/,
				loader: 'file-loader?name=fonts/[name].[hash].[ext]?'
			},
			{
				test: /\.(png|jpe?g|gif|svg)$/,
				loader: 'file-loader?name=img/[name].[hash].[ext]?'
			},
			{
				test: /\.css$/,
				use: ExtractTextPlugin.extract({
					fallback: "style-loader",
					use: "css-loader"
				})
			},
			{
				test: /\.less$/,
				use: ExtractTextPlugin.extract({
					fallback: "style-loader",
					use: "css-loader!less-loader"
				})
			},
			{
				test: /\.html$/,
				use: 'raw-loader',
				exclude: [root('src/index.html')]
			},
			{
				test: /\.json$/, loader: 'json-loader'
			}
		]
	};

	config.plugins = [
		new webpack.DefinePlugin({
			'process.env': { ENV: JSON.stringify(ENV) }
		}),
		new webpack.ContextReplacementPlugin(
			/angular(\\|\/)core(\\|\/)(esm(\\|\/)src|src)(\\|\/)linker/,
			root('./src')
		)
	];

	if (!isTest) {
		config.plugins.push(
			new webpack.optimize.CommonsChunkPlugin({
				name: ['vendor', 'polyfills']
			}),
			new HtmlWebpackPlugin({
				template: 'src/index.html',
				chunksSortMode: 'dependency'
			}),
			new ExtractTextPlugin({ filename: 'css/[name].[hash].css' })
		);
	}

	config.devServer = {
		historyApiFallback: true,
		quiet: true,
		stats: 'minimal' // none (or false), errors-only, minimal, normal (or true) and verbose
	};

	return config;
}();

// Helper functions
function root(args) {
	args = Array.prototype.slice.call(arguments, 0);
	return path.join.apply(path, [__dirname].concat(args));
}<commit_msg>webpack: New config for ts files with alt options<commit_after>var path = require('path');
var webpack = require('webpack');
var HtmlWebpackPlugin = require('html-webpack-plugin');
var ExtractTextPlugin = require('extract-text-webpack-plugin');

/**
 * Env
 * Get npm lifecycle event to identify the environment
 */
var ENV = process.env.npm_lifecycle_event;
var isTestWatch = ENV === 'test-watch';
var isTest = ENV === 'test' || isTestWatch;
// var isProd = ENV === 'build'; not using it right now //

module.exports = function makeWebpackConfig() {

	var config = {};

	config.devtool = isTest ? 'inline-source-map' : 'eval-source-map';

	if (!isTest) {
		config.entry = isTest ? {} : {
			'polyfills': './src/polyfills.ts',
			'vendor': './src/vendor.ts',
			'app': './src/main.ts'
		};
	}

	config.output = isTest ? {} : {
		path: root('dist'),
		publicPath: 'http://localhost:8080/',
		filename: 'js/[name].js',
		chunkFilename: '[id].chunk.js'
	};

	config.resolve = {
		extensions: ['.ts', '.js', '.json', '.css', '.less', '.html']
	};

	var atlOptions = '';

	if (isTest && !isTestWatch) {
		// awesome-typescript-loader needs to output inlineSourceMap for code coverage to work with source maps.
		atlOptions = 'inlineSourceMap=true&sourceMap=false';
	}

	config.module = {
		rules: [
			{
				test: /\.ts$/,
				loaders: ['awesome-typescript-loader?' + atlOptions, 'angular2-template-loader'],
				exclude: [isTest ? /\.(e2e)\.ts$/ : /\.(spec|e2e)\.ts$/, /node_modules\/(?!(ng2-.+))/]
			},
			{
				test: /\.ts$/,
				enforce: 'pre',
				loader: 'tslint-loader'
			},
			{
				test: /\.(png|jpe?g|gif|svg|otf|woff|woff2|ttf|eot|ico)(\?v=[0-9]\.[0-9]\.[0-9])?$/,
				loader: 'file-loader?name=fonts/[name].[hash].[ext]?'
			},
			{
				test: /\.(png|jpe?g|gif|svg)$/,
				loader: 'file-loader?name=img/[name].[hash].[ext]?'
			},
			{
				test: /\.css$/,
				use: ExtractTextPlugin.extract({
					fallback: "style-loader",
					use: "css-loader"
				})
			},
			{
				test: /\.less$/,
				use: ExtractTextPlugin.extract({
					fallback: "style-loader",
					use: "css-loader!less-loader"
				})
			},
			{
				test: /\.html$/,
				use: 'raw-loader',
				exclude: [root('src/index.html')]
			},
			{
				test: /\.json$/, loader: 'json-loader'
			}
		]
	};

	config.plugins = [
		new webpack.DefinePlugin({
			'process.env': { ENV: JSON.stringify(ENV) }
		}),
		new webpack.ContextReplacementPlugin(
			/angular(\\|\/)core(\\|\/)(esm(\\|\/)src|src)(\\|\/)linker/,
			root('./src')
		)
	];

	if (!isTest) {
		config.plugins.push(
			new webpack.optimize.CommonsChunkPlugin({
				name: ['vendor', 'polyfills']
			}),
			new HtmlWebpackPlugin({
				template: 'src/index.html',
				chunksSortMode: 'dependency'
			}),
			new ExtractTextPlugin({ filename: 'css/[name].[hash].css' })
		);
	}

	config.devServer = {
		historyApiFallback: true,
		quiet: true,
		stats: 'minimal' // none (or false), errors-only, minimal, normal (or true) and verbose
	};

	return config;
}();

// Helper functions
function root(args) {
	args = Array.prototype.slice.call(arguments, 0);
	return path.join.apply(path, [__dirname].concat(args));
}<|endoftext|>


<commit_before>/* --------------------------------------------------------------------
 * Fill in module info here.
 */

var info = {
    entries: {
        "apps/apps": [
            "apps/index.jsx"
        ],

        "dashboard/dashboard": [
            "dashboard/list.es6",
        ],

        "docker/docker": [
            "docker/containers.js"
        ],
        "docker/console": [
            "docker/console.js",
        ],

        "kdump/kdump": [
            "kdump/kdump.js",
            "kdump/kdump.css",
        ],

        "kubernetes/kubernetes": [
            "kubernetes/styles/main.less",
            "kubernetes/scripts/main.js",
        ],
        "kubernetes/registry": [
            "kubernetes/styles/registry.less",
            "kubernetes/scripts/registry.js",
        ],

        "machines/machines": [
            "machines/index.es6",
            "machines/machines.less",
        ],

        "networkmanager/network": [
            "networkmanager/interfaces.js",
            "networkmanager/utils.js"
        ],

        "networkmanager/firewall": [
            "networkmanager/firewall.jsx"
        ],

        "ovirt/ovirt": [
            "ovirt/index.js",
            "ovirt/ovirt.less",
        ],

        "playground/exception": [
            "playground/exception.js",
        ],
        "playground/jquery-patterns": [
            "playground/jquery-patterns.js",
        ],
        "playground/metrics": [
            "playground/metrics.js",
        ],
        "playground/pkgs": [
            "playground/pkgs.js",
        ],
        "playground/plot": [
            "playground/plot.js",
        ],
        "playground/react-patterns": [
            "playground/react-patterns",
        ],
        "playground/service": [
            "playground/service",
        ],
        "playground/speed": [
            "playground/speed",
        ],
        "playground/test": [
            "playground/test",
        ],
        "playground/translate": [
            "playground/translate",
        ],

        "realmd/domain": [
            "realmd/operation.js",
        ],

        "selinux/selinux": [
            "selinux/setroubleshoot.js",
            "selinux/setroubleshoot.css",
        ],

        "shell/index": [
            "shell/index.js",
            "shell/shell.less",
        ],
        "shell/index-stub": [
            "shell/index-stub.js",
        ],
        "shell/index-no-machines": [
            "shell/index-no-machines.js",
        ],

        "sosreport/sosreport": [
            "sosreport/index.js",
            "sosreport/sosreport.css",
        ],

        "storaged/storage": [
            "storaged/devices.js"
        ],

        "subscriptions/subscriptions": [
            "subscriptions/main.js",
            "subscriptions/subscriptions.css",
        ],

        "systemd/services": [
            "systemd/init.es6",
            "systemd/services.css",
        ],
        "systemd/logs": [
            "systemd/logs.js",
        ],
        "systemd/system": [
            "systemd/host.es6",
            "systemd/host.css",
        ],
        "systemd/terminal": [
            "systemd/terminal.jsx",
            "systemd/terminal.css",
        ],
        "systemd/hwinfo": [
            "systemd/hwinfo.jsx",
            "systemd/hwinfo.css",
        ],

        "tuned/performance": [
            "tuned/dialog.js",
        ],

        "packagekit/updates": [
            "packagekit/updates.jsx",
            "packagekit/updates.less",
        ],

        "users/users": [
            "users/local.es6",
            "users/users.css",
        ]
    },

    tests: [
        "docker/test-docker",

        "kdump/test-config-client",

        "lib/test-dummy",
        "lib/test-journal-renderer",
        "lib/test-machines",
        "lib/test-patterns",

        "networkmanager/test-utils",

        "storaged/test-util",

        "kubernetes/scripts/test-utils",
        "kubernetes/scripts/test-images",
        "kubernetes/scripts/test-projects",
        "kubernetes/scripts/test-nodes",
        "kubernetes/scripts/test-kube-client",
        "kubernetes/scripts/test-tags",
        "kubernetes/scripts/test-connection",
        "kubernetes/scripts/test-volumes",

        "machines/test-machines",
    ],

    files: [
        "apps/index.html",
        "apps/default.png",

        "dashboard/index.html",

        "docker/console.html",
        "docker/index.html",
        "docker/images/drive-harddisk-symbolic.svg",

        "kdump/index.html",

        "kubernetes/override.json",
        "kubernetes/index.html",
        "kubernetes/registry.html",

        "machines/base.css",
        "machines/index.html",

        "networkmanager/index.html",
        "networkmanager/firewall.html",
        "networkmanager/manifest.json",

        "ovirt/index.html",

        "packagekit/index.html",

        "playground/exception.html",
        "playground/hammer.gif",
        "playground/jquery-patterns.html",
        "playground/metrics.html",
        "playground/pkgs.html",
        "playground/plot.html",
        "playground/po.js",
        "playground/react-patterns.html",
        "playground/service.html",
        "playground/speed.html",
        "playground/test.html",
        "playground/translate.html",

        "selinux/setroubleshoot.html",

        "shell/images/server-error.png",
        "shell/images/server-large.png",
        "shell/images/server-small.png",
        "shell/index.html",
        "shell/simple.html",
        "shell/shell.html",
        "shell/stub.html",

        "sosreport/index.html",
        "sosreport/sosreport.png",

        "storaged/index.html",
        "storaged/images/storage-array.png",
        "storaged/images/storage-disk.png",

        "subscriptions/index.html",

        "systemd/index.html",
        "systemd/logs.html",
        "systemd/services.html",
        "systemd/terminal.html",
        "systemd/hwinfo.html",

        "users/index.html",
    ]
};

var externals = {
    "cockpit": "cockpit",
    "jquery": "jQuery",
};

/* ---------------------------------------------------------------------
 * Implementation
 */

var webpack = require("webpack");
var copy = require("copy-webpack-plugin");
var html = require('html-webpack-plugin');
var extract = require("extract-text-webpack-plugin");
var extend = require("extend");
var path = require("path");
var fs = require("fs");

/* These can be overridden, typically from the Makefile.am */
var srcdir = process.env.SRCDIR || __dirname;
var builddir = process.env.BUILDDIR || __dirname;
var distdir = builddir + path.sep + "dist";
var libdir = path.resolve(srcdir, "pkg" + path.sep + "lib");
var nodedir = path.resolve(srcdir, "node_modules");
var section = process.env.ONLYDIR || null;

/* A standard nodejs and webpack pattern */
var production = process.env.NODE_ENV === 'production';

/*
 * Note that we're avoiding the use of path.join as webpack and nodejs
 * want relative paths that start with ./ explicitly.
 *
 * In addition we mimic the VPATH style functionality of GNU Makefile
 * where we first check builddir, and then srcdir. In order to avoid
 * people having to run ./configure to hack on Cockpit we also help
 * resolve files that have a '.in' suffix if the resulting file
 * doesn't exist.
 */

function vpath(/* ... */) {
    var filename = Array.prototype.join.call(arguments, path.sep);
    var expanded = builddir + path.sep + filename;
    if (fs.existsSync(expanded))
        return expanded;
    expanded = srcdir + path.sep + filename;
    if (!fs.existsSync(expanded) && fs.existsSync(expanded + ".in"))
        return expanded + ".in";
    return expanded;
}

/* Qualify all the paths in entries */
Object.keys(info.entries).forEach(function(key) {
    if (section && key.indexOf(section) !== 0) {
        delete info.entries[key];
        return;
    }

    info.entries[key] = info.entries[key].map(function(value) {
        if (value.indexOf("/") === -1)
            return value;
        else
            return vpath("pkg", value);
    });
});

/* Qualify all the paths in files listed */
var files = [];
info.files.forEach(function(value) {
    if (!section || value.indexOf(section) === 0)
        files.push({ from: vpath("pkg", value), to: value });
});
info.files = files;

var plugins = [
    new webpack.DefinePlugin({
        'process.env': {
            'NODE_ENV': JSON.stringify(production ? 'production' : 'development')
        }
    }),
    new copy(info.files),
    new extract("[name].css"),
];

var output = {
    path: distdir,
    filename: "[name].js",
    sourceMapFilename: "[file].map",
};

/* Only minimize when in production mode */
if (production) {
    plugins.unshift(new webpack.optimize.UglifyJsPlugin({
        beautify: true,
        compress: {
            warnings: false
        },
    }));

    /* Rename output files when minimizing */
    output.filename = "[name].min.js";
}

/* Fill in the tests properly */
info.tests.forEach(function(test) {
    var ext = production ? ".min.js" : ".js";
    if (!section || test.indexOf(section) === 0) {
        info.entries[test] = vpath("pkg", test + ".js");
        plugins.push(new html({
            title: path.basename(test),
            filename: test + ".html",
            template: libdir + path.sep + "qunit-template.html",
            builddir: test.split("/").map(function() { return "../" }).join(""),
            script: path.basename(test + ext),
            inject: false,
        }));
    }
});

var aliases = {
    "angular": "angular/angular.js",
    "angular-route": "angular-route/angular-route.js",
    "d3": "d3/d3.js",
    "moment": "moment/moment.js",
    "term": "term.js-cockpit/src/term.js"
};

/* HACK: To get around redux warning about reminimizing code */
if (production)
    aliases["redux/dist/redux"] = "redux/dist/redux.min.js";

module.exports = {
    resolve: {
        alias: aliases,
        modulesDirectories: [ libdir, nodedir ],
        extensions: ["", ".js", ".json", ".less"]
    },
    resolveLoader: {
        root: nodedir
    },
    entry: info.entries,
    output: output,
    externals: externals,
    plugins: plugins,

    devtool: "source-map",

    module: {
        preLoaders: [
            {
                test: /\/src\/.*\.js$/,
                exclude: /\/node_modules\/.*\//, // exclude external dependencies
                loader: "jshint-loader"
            },
            {
                test: /\/pkg\/.*\.js$/,
                exclude: /\/node_modules\/.*\//, // exclude external dependencies
                loader: "eslint-loader"
            },
            {
                test: /\.es6$/,
                exclude: /\/node_modules\/.*\//, // exclude external dependencies
                loader: "eslint-loader"
            },
            {
                test: /\.jsx$/,
                exclude: /\/node_modules\/.*\//, // exclude external dependencies
                loader: "eslint-loader"
            }
        ],
        loaders: [
            {
                test: /\.js$/,
                exclude: /\/node_modules\/.*\//, // exclude external dependencies
                loader: 'strict' // Adds "use strict"
            },
            /* these are called *.js, but are ES6 */
            {
                test: /\/node_modules\/@novnc.*\.js$/,
                loader: "babel-loader"
            },
            {
                test: /\.jsx$/,
                loader: "babel-loader"
            },
            {
                test: /\.es6$/,
                loader: "babel-loader"
            },
            {
                test: /\.css$/,
                loader: extract.extract("css-loader?minimize=&root=" + libdir)
            },
            {
                test: /\.less$/,
                loader: extract.extract("css-loader?sourceMap&minimize=!less-loader?sourceMap&compress=false")
            },
            {
                test: /views\/[^\/]+\.html$/,
                loader: "ng-cache?prefix=[dir]"
            },
            {
                test: /[\/]angular\.js$/,
                loader: "exports?angular"
            }
        ],
    },

    jshint: {
        emitErrors: true,
        failOnHint: true,
        latedef: "nofunc",
        sub: true,
        multistr: true,
        undef: true,
        unused: "vars",
        predef: [ "window", "document", "console" ],
        lastsemic : true,
    },
};
<commit_msg>webpack: Tighten jshint path match<commit_after>/* --------------------------------------------------------------------
 * Fill in module info here.
 */

var info = {
    entries: {
        "apps/apps": [
            "apps/index.jsx"
        ],

        "dashboard/dashboard": [
            "dashboard/list.es6",
        ],

        "docker/docker": [
            "docker/containers.js"
        ],
        "docker/console": [
            "docker/console.js",
        ],

        "kdump/kdump": [
            "kdump/kdump.js",
            "kdump/kdump.css",
        ],

        "kubernetes/kubernetes": [
            "kubernetes/styles/main.less",
            "kubernetes/scripts/main.js",
        ],
        "kubernetes/registry": [
            "kubernetes/styles/registry.less",
            "kubernetes/scripts/registry.js",
        ],

        "machines/machines": [
            "machines/index.es6",
            "machines/machines.less",
        ],

        "networkmanager/network": [
            "networkmanager/interfaces.js",
            "networkmanager/utils.js"
        ],

        "networkmanager/firewall": [
            "networkmanager/firewall.jsx"
        ],

        "ovirt/ovirt": [
            "ovirt/index.js",
            "ovirt/ovirt.less",
        ],

        "playground/exception": [
            "playground/exception.js",
        ],
        "playground/jquery-patterns": [
            "playground/jquery-patterns.js",
        ],
        "playground/metrics": [
            "playground/metrics.js",
        ],
        "playground/pkgs": [
            "playground/pkgs.js",
        ],
        "playground/plot": [
            "playground/plot.js",
        ],
        "playground/react-patterns": [
            "playground/react-patterns",
        ],
        "playground/service": [
            "playground/service",
        ],
        "playground/speed": [
            "playground/speed",
        ],
        "playground/test": [
            "playground/test",
        ],
        "playground/translate": [
            "playground/translate",
        ],

        "realmd/domain": [
            "realmd/operation.js",
        ],

        "selinux/selinux": [
            "selinux/setroubleshoot.js",
            "selinux/setroubleshoot.css",
        ],

        "shell/index": [
            "shell/index.js",
            "shell/shell.less",
        ],
        "shell/index-stub": [
            "shell/index-stub.js",
        ],
        "shell/index-no-machines": [
            "shell/index-no-machines.js",
        ],

        "sosreport/sosreport": [
            "sosreport/index.js",
            "sosreport/sosreport.css",
        ],

        "storaged/storage": [
            "storaged/devices.js"
        ],

        "subscriptions/subscriptions": [
            "subscriptions/main.js",
            "subscriptions/subscriptions.css",
        ],

        "systemd/services": [
            "systemd/init.es6",
            "systemd/services.css",
        ],
        "systemd/logs": [
            "systemd/logs.js",
        ],
        "systemd/system": [
            "systemd/host.es6",
            "systemd/host.css",
        ],
        "systemd/terminal": [
            "systemd/terminal.jsx",
            "systemd/terminal.css",
        ],
        "systemd/hwinfo": [
            "systemd/hwinfo.jsx",
            "systemd/hwinfo.css",
        ],

        "tuned/performance": [
            "tuned/dialog.js",
        ],

        "packagekit/updates": [
            "packagekit/updates.jsx",
            "packagekit/updates.less",
        ],

        "users/users": [
            "users/local.es6",
            "users/users.css",
        ]
    },

    tests: [
        "docker/test-docker",

        "kdump/test-config-client",

        "lib/test-dummy",
        "lib/test-journal-renderer",
        "lib/test-machines",
        "lib/test-patterns",

        "networkmanager/test-utils",

        "storaged/test-util",

        "kubernetes/scripts/test-utils",
        "kubernetes/scripts/test-images",
        "kubernetes/scripts/test-projects",
        "kubernetes/scripts/test-nodes",
        "kubernetes/scripts/test-kube-client",
        "kubernetes/scripts/test-tags",
        "kubernetes/scripts/test-connection",
        "kubernetes/scripts/test-volumes",

        "machines/test-machines",
    ],

    files: [
        "apps/index.html",
        "apps/default.png",

        "dashboard/index.html",

        "docker/console.html",
        "docker/index.html",
        "docker/images/drive-harddisk-symbolic.svg",

        "kdump/index.html",

        "kubernetes/override.json",
        "kubernetes/index.html",
        "kubernetes/registry.html",

        "machines/base.css",
        "machines/index.html",

        "networkmanager/index.html",
        "networkmanager/firewall.html",
        "networkmanager/manifest.json",

        "ovirt/index.html",

        "packagekit/index.html",

        "playground/exception.html",
        "playground/hammer.gif",
        "playground/jquery-patterns.html",
        "playground/metrics.html",
        "playground/pkgs.html",
        "playground/plot.html",
        "playground/po.js",
        "playground/react-patterns.html",
        "playground/service.html",
        "playground/speed.html",
        "playground/test.html",
        "playground/translate.html",

        "selinux/setroubleshoot.html",

        "shell/images/server-error.png",
        "shell/images/server-large.png",
        "shell/images/server-small.png",
        "shell/index.html",
        "shell/simple.html",
        "shell/shell.html",
        "shell/stub.html",

        "sosreport/index.html",
        "sosreport/sosreport.png",

        "storaged/index.html",
        "storaged/images/storage-array.png",
        "storaged/images/storage-disk.png",

        "subscriptions/index.html",

        "systemd/index.html",
        "systemd/logs.html",
        "systemd/services.html",
        "systemd/terminal.html",
        "systemd/hwinfo.html",

        "users/index.html",
    ]
};

var externals = {
    "cockpit": "cockpit",
    "jquery": "jQuery",
};

/* ---------------------------------------------------------------------
 * Implementation
 */

var webpack = require("webpack");
var copy = require("copy-webpack-plugin");
var html = require('html-webpack-plugin');
var extract = require("extract-text-webpack-plugin");
var extend = require("extend");
var path = require("path");
var fs = require("fs");

/* These can be overridden, typically from the Makefile.am */
var srcdir = process.env.SRCDIR || __dirname;
var builddir = process.env.BUILDDIR || __dirname;
var distdir = builddir + path.sep + "dist";
var libdir = path.resolve(srcdir, "pkg" + path.sep + "lib");
var nodedir = path.resolve(srcdir, "node_modules");
var section = process.env.ONLYDIR || null;

/* A standard nodejs and webpack pattern */
var production = process.env.NODE_ENV === 'production';

/*
 * Note that we're avoiding the use of path.join as webpack and nodejs
 * want relative paths that start with ./ explicitly.
 *
 * In addition we mimic the VPATH style functionality of GNU Makefile
 * where we first check builddir, and then srcdir. In order to avoid
 * people having to run ./configure to hack on Cockpit we also help
 * resolve files that have a '.in' suffix if the resulting file
 * doesn't exist.
 */

function vpath(/* ... */) {
    var filename = Array.prototype.join.call(arguments, path.sep);
    var expanded = builddir + path.sep + filename;
    if (fs.existsSync(expanded))
        return expanded;
    expanded = srcdir + path.sep + filename;
    if (!fs.existsSync(expanded) && fs.existsSync(expanded + ".in"))
        return expanded + ".in";
    return expanded;
}

/* Qualify all the paths in entries */
Object.keys(info.entries).forEach(function(key) {
    if (section && key.indexOf(section) !== 0) {
        delete info.entries[key];
        return;
    }

    info.entries[key] = info.entries[key].map(function(value) {
        if (value.indexOf("/") === -1)
            return value;
        else
            return vpath("pkg", value);
    });
});

/* Qualify all the paths in files listed */
var files = [];
info.files.forEach(function(value) {
    if (!section || value.indexOf(section) === 0)
        files.push({ from: vpath("pkg", value), to: value });
});
info.files = files;

var plugins = [
    new webpack.DefinePlugin({
        'process.env': {
            'NODE_ENV': JSON.stringify(production ? 'production' : 'development')
        }
    }),
    new copy(info.files),
    new extract("[name].css"),
];

var output = {
    path: distdir,
    filename: "[name].js",
    sourceMapFilename: "[file].map",
};

/* Only minimize when in production mode */
if (production) {
    plugins.unshift(new webpack.optimize.UglifyJsPlugin({
        beautify: true,
        compress: {
            warnings: false
        },
    }));

    /* Rename output files when minimizing */
    output.filename = "[name].min.js";
}

/* Fill in the tests properly */
info.tests.forEach(function(test) {
    var ext = production ? ".min.js" : ".js";
    if (!section || test.indexOf(section) === 0) {
        info.entries[test] = vpath("pkg", test + ".js");
        plugins.push(new html({
            title: path.basename(test),
            filename: test + ".html",
            template: libdir + path.sep + "qunit-template.html",
            builddir: test.split("/").map(function() { return "../" }).join(""),
            script: path.basename(test + ext),
            inject: false,
        }));
    }
});

var aliases = {
    "angular": "angular/angular.js",
    "angular-route": "angular-route/angular-route.js",
    "d3": "d3/d3.js",
    "moment": "moment/moment.js",
    "term": "term.js-cockpit/src/term.js"
};

/* HACK: To get around redux warning about reminimizing code */
if (production)
    aliases["redux/dist/redux"] = "redux/dist/redux.min.js";

module.exports = {
    resolve: {
        alias: aliases,
        modulesDirectories: [ libdir, nodedir ],
        extensions: ["", ".js", ".json", ".less"]
    },
    resolveLoader: {
        root: nodedir
    },
    entry: info.entries,
    output: output,
    externals: externals,
    plugins: plugins,

    devtool: "source-map",

    module: {
        preLoaders: [
            {
                test: /\/src\/(base1|ws)\/[^/]*\.js$/,
                exclude: /\/node_modules\/.*\//, // exclude external dependencies
                loader: "jshint-loader"
            },
            {
                test: /\/pkg\/.*\.js$/,
                exclude: /\/node_modules\/.*\//, // exclude external dependencies
                loader: "eslint-loader"
            },
            {
                test: /\.es6$/,
                exclude: /\/node_modules\/.*\//, // exclude external dependencies
                loader: "eslint-loader"
            },
            {
                test: /\.jsx$/,
                exclude: /\/node_modules\/.*\//, // exclude external dependencies
                loader: "eslint-loader"
            }
        ],
        loaders: [
            {
                test: /\.js$/,
                exclude: /\/node_modules\/.*\//, // exclude external dependencies
                loader: 'strict' // Adds "use strict"
            },
            /* these are called *.js, but are ES6 */
            {
                test: /\/node_modules\/@novnc.*\.js$/,
                loader: "babel-loader"
            },
            {
                test: /\.jsx$/,
                loader: "babel-loader"
            },
            {
                test: /\.es6$/,
                loader: "babel-loader"
            },
            {
                test: /\.css$/,
                loader: extract.extract("css-loader?minimize=&root=" + libdir)
            },
            {
                test: /\.less$/,
                loader: extract.extract("css-loader?sourceMap&minimize=!less-loader?sourceMap&compress=false")
            },
            {
                test: /views\/[^\/]+\.html$/,
                loader: "ng-cache?prefix=[dir]"
            },
            {
                test: /[\/]angular\.js$/,
                loader: "exports?angular"
            }
        ],
    },

    jshint: {
        emitErrors: true,
        failOnHint: true,
        latedef: "nofunc",
        sub: true,
        multistr: true,
        undef: true,
        unused: "vars",
        predef: [ "window", "document", "console" ],
        lastsemic : true,
    },
};
<|endoftext|>