<commit_before>var path = require("path");
var webpack = require("webpack");
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
var Clean = require("clean-webpack-plugin");
var git = require("git-rev-sync");
require("es6-promise").polyfill();
const CopyWebpackPlugin = require("copy-webpack-plugin");
var locales = require("./app/assets/locales");
const HtmlWebpackPlugin = require("html-webpack-plugin");

/*
* For staging builds, set the version to the latest commit hash, for
* production set it to the package version
*/
let branch = !!process.env.BRANCH ? process.env.BRANCH : git.branch();
var __VERSION__ =
    branch === "develop" ? git.short() : require("./package.json").version;

// BASE APP DIR
var root_dir = path.resolve(__dirname);

module.exports = function(env) {
    // STYLE LOADERS
    var cssLoaders = [
        {
            loader: "style-loader"
        },
        {
            loader: "css-loader"
        },
        {
            loader: "postcss-loader"
        }
    ];

    var scssLoaders = [
        {
            loader: "style-loader"
        },
        {
            loader: "css-loader"
        },
        {
            loader: "postcss-loader"
        },
        {
            loader: "sass-loader",
            options: {
                outputStyle: "expanded"
            }
        }
    ];

    // OUTPUT PATH
    var outputPath = path.join(root_dir, "assets");

    // COMMON PLUGINS
    const baseUrl = env.electron ? "./" : "baseUrl" in env ? env.baseUrl : "/";

    /*
    * moment and react-intl include tons of locale files, use a regex and
    * ContextReplacementPlugin to only include certain locale files
    */
    let regexString = "";
    locales.forEach((l, i) => {
        regexString = regexString + (l + (i < locales.length - 1 ? "|" : ""));
    });
    const localeRegex = new RegExp(regexString);
    var plugins = [
        new HtmlWebpackPlugin({
            template: "!!handlebars-loader!app/assets/index.hbs",
            templateParameters: {
                title: "BitShares " + __VERSION__,
                INCLUDE_BASE: !!env.prod && !env.hash,
                PRODUCTION: !!env.prod,
                ELECTRON: !!env.electron
            }
        }),

        new webpack.DefinePlugin({
            APP_VERSION: JSON.stringify(__VERSION__),
            __ELECTRON__: !!env.electron,
            __HASH_HISTORY__: !!env.hash,
            __BASE_URL__: JSON.stringify(baseUrl),
            __UI_API__: JSON.stringify(env.apiUrl),
            __TESTNET__: !!env.testnet,
            __DEPRECATED__: !!env.deprecated,
            DEFAULT_SYMBOL: "BTS",
            __GIT_BRANCH__: JSON.stringify(git.branch()),
            __PERFORMANCE_DEVTOOL__: !!env.perf_dev
        }),
        new webpack.ContextReplacementPlugin(
            /moment[\/\\]locale$/,
            localeRegex
        ),
        new webpack.ContextReplacementPlugin(
            /react-intl[\/\\]locale-data$/,
            localeRegex
        ),
        new CopyWebpackPlugin([
            {
                from: path.join(root_dir, "charting_library"),
                to: "charting_library"
            }
        ])
    ];
    if (env.prod) {
        // PROD OUTPUT PATH
        let outputDir = env.electron
            ? "electron"
            : env.hash
                ? !baseUrl
                    ? "hash-history"
                    : `hash-history_${baseUrl.replace("/", "")}`
                : "dist";
        outputPath = path.join(root_dir, "build", outputDir);

        // DIRECTORY CLEANER
        var cleanDirectories = [outputPath];

        // WRAP INTO CSS FILE
        cssLoaders = [
            {loader: MiniCssExtractPlugin.loader},
            {loader: "css-loader"},
            {
                loader: "postcss-loader",
                options: {
                    minimize: true,
                    debug: false
                }
            }
        ];
        scssLoaders = [
            {loader: MiniCssExtractPlugin.loader},
            {loader: "css-loader"},
            {
                loader: "postcss-loader",
                options: {
                    minimize: true,
                    debug: false
                }
            },
            {loader: "sass-loader", options: {outputStyle: "expanded"}}
        ];

        // PROD PLUGINS
        plugins.push(new Clean(cleanDirectories, {root: root_dir}));
        plugins.push(
            new webpack.DefinePlugin({
                __DEV__: false
            })
        );
        plugins.push(
            new MiniCssExtractPlugin({
                filename: "[name].[contenthash].css"
            })
        );
    } else {
        plugins.push(
            new webpack.DefinePlugin({
                "process.env": {NODE_ENV: JSON.stringify("development")},
                __DEV__: true
            })
        );
        plugins.push(new webpack.HotModuleReplacementPlugin());
    }

    plugins.push(
        new CopyWebpackPlugin(
            [
                {
                    from: path.join(
                        root_dir,
                        "app",
                        "assets",
                        "locales",
                        "*.json"
                    ),
                    to: path.join(outputPath, "[name].[ext]"),
                    toType: "template"
                },
                {
                    from: path.join(
                        root_dir,
                        "app",
                        "lib",
                        "common",
                        "dictionary_en.json"
                    ),
                    to: path.join(outputPath, "dictionary.json"),
                    toType: "file"
                },
                {
                    from: path.join(
                        root_dir,
                        "app",
                        "assets",
                        "outdated_browser.css"
                    ),
                    to: path.join(outputPath, "outdated_browser.css"),
                    toType: "file"
                }
            ],
            {}
        )
    );

    var config = {
        mode: env.noUgly ? "none" : env.prod ? "production" : "development",
        entry: {
            app: env.prod
                ? path.resolve(root_dir, "app/Main.js")
                : [
                      "webpack-hot-middleware/client",
                      "react-hot-loader/patch",
                      path.resolve(root_dir, "app/Main.js")
                  ]
        },
        output: {
            publicPath: env.prod ? "" : "/",
            path: outputPath,
            filename: env.prod ? "[name].[chunkhash].js" : "[name].js",
            chunkFilename: env.prod ? "[name].[chunkhash].js" : "[name].js",
            pathinfo: !env.prod,
            sourceMapFilename: "[name].js.map"
        },
        optimization: {
            splitChunks: {
                cacheGroups: {
                    styles: {
                        name: "styles",
                        test: /\.css$/,
                        chunks: "all",
                        enforce: true
                    },
                    vendor: {
                        name: "vendor",
                        test: /node_modules/,
                        chunks: "initial",
                        enforce: true
                    }
                }
            }
        },
        devtool:
            env.noUgly || !env.prod
                ? "inline-cheap-module-source-map"
                : "cheap-source-map",
        module: {
            rules: [
                {
                    // Test for a polyfill (or any file) and it won't be included in your
                    // bundle
                    test: /node-fetch/,
                    use: "null-loader"
                },
                {
                    test: /\.jsx$/,
                    include: [
                        path.join(root_dir, "app"),
                        path.join(
                            root_dir,
                            "node_modules/react-foundation-apps"
                        )
                    ],
                    use: [
                        {
                            loader: "babel-loader",
                            options: {
                                cacheDirectory: env.prod ? false : true,
                                plugins: ["react-hot-loader/babel"]
                            }
                        }
                    ]
                },
                {
                    test: /\.js$/,
                    include: [
                        path.join(root_dir, "app"),
                        path.join(root_dir, "node_modules/react-datepicker2"),
                        path.join(root_dir, "node_modules/alt-container"),
                        path.join(root_dir, "node_modules/alt-react")
                    ],
                    use: [
                        {
                            loader: "babel-loader",
                            options: {
                                compact: false,
                                cacheDirectory: env.prod ? false : true,
                                plugins: ["react-hot-loader/babel"]
                            }
                        }
                    ]
                },
                {
                    test: /\.mjs$/,
                    include: /node_modules/,
                    type: "javascript/auto"
                },
                {test: /\.coffee$/, loader: "coffee-loader"},
                {
                    test: /\.(coffee\.md|litcoffee)$/,
                    loader: "coffee-loader?literate"
                },
                {
                    test: /\.css$/,
                    use: cssLoaders
                },
                {
                    test: /\.scss$/,
                    use: scssLoaders
                },
                {
                    test: /\.png$/,
                    exclude: [
                        path.resolve(root_dir, "app/assets/asset-symbols"),
                        path.resolve(
                            root_dir,
                            "app/assets/language-dropdown/img"
                        )
                    ],
                    use: [
                        {
                            loader: "url-loader",
                            options: {
                                limit: 100000
                            }
                        }
                    ]
                },

                {
                    test: /\.woff$/,
                    use: [
                        {
                            loader: "url-loader",
                            options: {
                                limit: 100000,
                                mimetype: "application/font-woff"
                            }
                        }
                    ]
                },
                {
                    test: /.*\.svg$/,
                    exclude: [
                        path.resolve(root_dir, "app/assets/model-type-images"),
                        path.resolve(root_dir, "app/assets/bin-file")
                    ],
                    use: [
                        {
                            loader: "svg-inline-loader"
                        },
                        {
                            loader: "svgo-loader",
                            options: {
                                plugins: [
                                    {cleanupAttrs: true},
                                    {removeMetadata: true},
                                    {removeXMLNS: true},
                                    {removeViewBox: false}
                                ]
                            }
                        }
                    ]
                },
                {
                    test: /\.md/,
                    use: [
                        {
                            loader: "html-loader",
                            options: {
                                removeAttributeQuotes: false
                            }
                        },
                        {
                            loader: "markdown-loader",
                            options: {}
                        }
                    ]
                }
            ]
        },
        resolve: {
            modules: [
                path.resolve(root_dir, "app"),
                path.resolve(root_dir, "app/lib"),
                "node_modules"
            ],
            extensions: [".js", ".jsx", ".coffee", ".json"],
            mainFields: ["module", "jsnext:main", "browser", "main"],
            alias: {
                sanitize$: "xss",
                moment$: path.resolve(
                    root_dir,
                    "node_modules/moment/moment.js"
                ),
                bitsharesjs$: path.resolve(
                    root_dir,
                    "node_modules/bitsharesjs/"
                ),
                "bitshares-ui-style-guide$": path.resolve(
                    root_dir,
                    "node_modules/bitshares-ui-style-guide/dist/main.js"
                )
            }
        },
        plugins: plugins
    };

    return config;
};
<commit_msg>Change webpack config to accomodate service worker. Key imports successfully.<commit_after>var path = require("path");
var webpack = require("webpack");
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
var Clean = require("clean-webpack-plugin");
var git = require("git-rev-sync");
require("es6-promise").polyfill();
const CopyWebpackPlugin = require("copy-webpack-plugin");
var locales = require("./app/assets/locales");
const HtmlWebpackPlugin = require("html-webpack-plugin");

/*
* For staging builds, set the version to the latest commit hash, for
* production set it to the package version
*/
let branch = !!process.env.BRANCH ? process.env.BRANCH : git.branch();
var __VERSION__ =
    branch === "develop" ? git.short() : require("./package.json").version;

// BASE APP DIR
var root_dir = path.resolve(__dirname);

module.exports = function(env) {
    // STYLE LOADERS
    var cssLoaders = [
        {
            loader: "style-loader"
        },
        {
            loader: "css-loader"
        },
        {
            loader: "postcss-loader"
        }
    ];

    var scssLoaders = [
        {
            loader: "style-loader"
        },
        {
            loader: "css-loader"
        },
        {
            loader: "postcss-loader"
        },
        {
            loader: "sass-loader",
            options: {
                outputStyle: "expanded"
            }
        }
    ];

    // OUTPUT PATH
    var outputPath = path.join(root_dir, "assets");

    // COMMON PLUGINS
    const baseUrl = env.electron ? "./" : "baseUrl" in env ? env.baseUrl : "/";

    /*
    * moment and react-intl include tons of locale files, use a regex and
    * ContextReplacementPlugin to only include certain locale files
    */
    let regexString = "";
    locales.forEach((l, i) => {
        regexString = regexString + (l + (i < locales.length - 1 ? "|" : ""));
    });
    const localeRegex = new RegExp(regexString);
    var plugins = [
        new HtmlWebpackPlugin({
            template: "!!handlebars-loader!app/assets/index.hbs",
            templateParameters: {
                title: "BitShares " + __VERSION__,
                INCLUDE_BASE: !!env.prod && !env.hash,
                PRODUCTION: !!env.prod,
                ELECTRON: !!env.electron
            }
        }),

        new webpack.DefinePlugin({
            APP_VERSION: JSON.stringify(__VERSION__),
            __ELECTRON__: !!env.electron,
            __HASH_HISTORY__: !!env.hash,
            __BASE_URL__: JSON.stringify(baseUrl),
            __UI_API__: JSON.stringify(env.apiUrl),
            __TESTNET__: !!env.testnet,
            __DEPRECATED__: !!env.deprecated,
            DEFAULT_SYMBOL: "BTS",
            __GIT_BRANCH__: JSON.stringify(git.branch()),
            __PERFORMANCE_DEVTOOL__: !!env.perf_dev
        }),
        new webpack.ContextReplacementPlugin(
            /moment[\/\\]locale$/,
            localeRegex
        ),
        new webpack.ContextReplacementPlugin(
            /react-intl[\/\\]locale-data$/,
            localeRegex
        ),
        new CopyWebpackPlugin([
            {
                from: path.join(root_dir, "charting_library"),
                to: "charting_library"
            }
        ])
    ];
    if (env.prod) {
        // PROD OUTPUT PATH
        let outputDir = env.electron
            ? "electron"
            : env.hash
                ? !baseUrl
                    ? "hash-history"
                    : `hash-history_${baseUrl.replace("/", "")}`
                : "dist";
        outputPath = path.join(root_dir, "build", outputDir);

        // DIRECTORY CLEANER
        var cleanDirectories = [outputPath];

        // WRAP INTO CSS FILE
        cssLoaders = [
            {loader: MiniCssExtractPlugin.loader},
            {loader: "css-loader"},
            {
                loader: "postcss-loader",
                options: {
                    minimize: true,
                    debug: false
                }
            }
        ];
        scssLoaders = [
            {loader: MiniCssExtractPlugin.loader},
            {loader: "css-loader"},
            {
                loader: "postcss-loader",
                options: {
                    minimize: true,
                    debug: false
                }
            },
            {loader: "sass-loader", options: {outputStyle: "expanded"}}
        ];

        // PROD PLUGINS
        plugins.push(new Clean(cleanDirectories, {root: root_dir}));
        plugins.push(
            new webpack.DefinePlugin({
                __DEV__: false
            })
        );
        plugins.push(
            new MiniCssExtractPlugin({
                filename: "[name].[contenthash].css"
            })
        );
    } else {
        plugins.push(
            new webpack.DefinePlugin({
                "process.env": {NODE_ENV: JSON.stringify("development")},
                __DEV__: true
            })
        );
        plugins.push(new webpack.HotModuleReplacementPlugin());
    }

    plugins.push(
        new CopyWebpackPlugin(
            [
                {
                    from: path.join(
                        root_dir,
                        "app",
                        "assets",
                        "locales",
                        "*.json"
                    ),
                    to: path.join(outputPath, "[name].[ext]"),
                    toType: "template"
                },
                {
                    from: path.join(
                        root_dir,
                        "app",
                        "lib",
                        "common",
                        "dictionary_en.json"
                    ),
                    to: path.join(outputPath, "dictionary.json"),
                    toType: "file"
                },
                {
                    from: path.join(
                        root_dir,
                        "app",
                        "assets",
                        "outdated_browser.css"
                    ),
                    to: path.join(outputPath, "outdated_browser.css"),
                    toType: "file"
                }
            ],
            {}
        )
    );

    var config = {
        mode: env.noUgly ? "none" : env.prod ? "production" : "development",
        entry: {
            app: env.prod
                ? path.resolve(root_dir, "app/Main.js")
                : [
                      "webpack-hot-middleware/client",
                      "react-hot-loader/patch",
                      path.resolve(root_dir, "app/Main.js")
                  ]
        },
        output: {
            publicPath: env.prod ? "" : "/",
            path: outputPath,
            filename: env.prod ? "[name].[chunkhash].js" : "[name].js",
            chunkFilename: env.prod ? "[name].[chunkhash].js" : "[name].js",
            pathinfo: !env.prod,
            sourceMapFilename: "[name].js.map",
            globalObject: "this"
        },
        optimization: {
            splitChunks: {
                cacheGroups: {
                    styles: {
                        name: "styles",
                        test: /\.css$/,
                        chunks: "all",
                        enforce: true
                    },
                    vendor: {
                        name: "vendor",
                        test: /node_modules/,
                        chunks: "initial",
                        enforce: true
                    }
                }
            }
        },
        devtool:
            env.noUgly || !env.prod
                ? "inline-cheap-module-source-map"
                : "cheap-source-map",
        module: {
            rules: [
                {
                    // Test for a polyfill (or any file) and it won't be included in your
                    // bundle
                    test: /node-fetch/,
                    use: "null-loader"
                },
                {
                    test: /\.jsx$/,
                    include: [
                        path.join(root_dir, "app"),
                        path.join(
                            root_dir,
                            "node_modules/react-foundation-apps"
                        )
                    ],
                    use: [
                        {
                            loader: "babel-loader",
                            options: {
                                cacheDirectory: env.prod ? false : true,
                                plugins: ["react-hot-loader/babel"]
                            }
                        }
                    ]
                },
                {
                    test: /\.js$/,
                    include: [
                        path.join(root_dir, "app"),
                        path.join(root_dir, "node_modules/react-datepicker2"),
                        path.join(root_dir, "node_modules/alt-container"),
                        path.join(root_dir, "node_modules/alt-react")
                    ],
                    use: [
                        {
                            loader: "babel-loader",
                            options: {
                                compact: false,
                                cacheDirectory: env.prod ? false : true,
                                plugins: ["react-hot-loader/babel"]
                            }
                        }
                    ]
                },
                {
                    test: /\.mjs$/,
                    include: /node_modules/,
                    type: "javascript/auto"
                },
                {test: /\.coffee$/, loader: "coffee-loader"},
                {
                    test: /\.(coffee\.md|litcoffee)$/,
                    loader: "coffee-loader?literate"
                },
                {
                    test: /\.css$/,
                    use: cssLoaders
                },
                {
                    test: /\.scss$/,
                    use: scssLoaders
                },
                {
                    test: /\.png$/,
                    exclude: [
                        path.resolve(root_dir, "app/assets/asset-symbols"),
                        path.resolve(
                            root_dir,
                            "app/assets/language-dropdown/img"
                        )
                    ],
                    use: [
                        {
                            loader: "url-loader",
                            options: {
                                limit: 100000
                            }
                        }
                    ]
                },

                {
                    test: /\.woff$/,
                    use: [
                        {
                            loader: "url-loader",
                            options: {
                                limit: 100000,
                                mimetype: "application/font-woff"
                            }
                        }
                    ]
                },
                {
                    test: /.*\.svg$/,
                    exclude: [
                        path.resolve(root_dir, "app/assets/model-type-images"),
                        path.resolve(root_dir, "app/assets/bin-file")
                    ],
                    use: [
                        {
                            loader: "svg-inline-loader"
                        },
                        {
                            loader: "svgo-loader",
                            options: {
                                plugins: [
                                    {cleanupAttrs: true},
                                    {removeMetadata: true},
                                    {removeXMLNS: true},
                                    {removeViewBox: false}
                                ]
                            }
                        }
                    ]
                },
                {
                    test: /\.md/,
                    use: [
                        {
                            loader: "html-loader",
                            options: {
                                removeAttributeQuotes: false
                            }
                        },
                        {
                            loader: "markdown-loader",
                            options: {}
                        }
                    ]
                }
            ]
        },
        resolve: {
            modules: [
                path.resolve(root_dir, "app"),
                path.resolve(root_dir, "app/lib"),
                "node_modules"
            ],
            extensions: [".js", ".jsx", ".coffee", ".json"],
            mainFields: ["module", "jsnext:main", "browser", "main"],
            alias: {
                sanitize$: "xss",
                moment$: path.resolve(
                    root_dir,
                    "node_modules/moment/moment.js"
                ),
                bitsharesjs$: path.resolve(
                    root_dir,
                    "node_modules/bitsharesjs/"
                ),
                "bitshares-ui-style-guide$": path.resolve(
                    root_dir,
                    "node_modules/bitshares-ui-style-guide/dist/main.js"
                )
            }
        },
        plugins: plugins
    };

    return config;
};
<|endoftext|>


<commit_before>const config = require('config')
const WebpackCdnPlugin = require('webpack-cdn-plugin')
const HtmlWebpackPlugin = require('html-webpack-plugin')
const MiniCssExtractPlugin = require('mini-css-extract-plugin')
const CssMinimizerPlugin = require('css-minimizer-webpack-plugin')
const packageJson = require('./package.json')

module.exports = (_env, argv) => {
	const dev = argv.mode === 'development'
	const reactMode = dev ? 'development' : 'production.min'
	const min = dev ? '' : '.min'

	return {
		entry: {
			app: './web'
		},
		output: {
			publicPath: '/',
			filename: '[name].[chunkhash:8].js'
		},
		module: {
			rules: [
				{
					test: /\.tsx?$/,
					loader: 'ts-loader'
				},
				{
					test: /\.(c|le)ss$/,
					use: [
						MiniCssExtractPlugin.loader,
						'css-loader',
						{
							loader: 'less-loader',
							options: {
								lessOptions: {
									javascriptEnabled: true
								}
							}
						}
					]
				}
			]
		},
		resolve: {
			extensions: ['.tsx', '.ts', '.js']
		},
		plugins: [
			new HtmlWebpackPlugin({
				title: 'DOJ',
				inject: 'body',
				favicon: 'web/logo.png',
				meta: {
					author: packageJson.author,
					description: packageJson.description,
					keywords: packageJson.keywords.join(',')
				}
			}),
			new WebpackCdnPlugin({
				modules: [
					{ name: 'moment', path: `min/moment.min.js` },
					{ name: 'axios', path: `dist/axios${min}.js` },
					{ name: 'ace-builds', var: 'ace', paths: [`src-min-noconflict/ace.js`, `src-min-noconflict/ext-static_highlight.js`] },
					{ name: 'katex', path: `dist/katex${min}.js`, style: `dist/katex${min}.css` },
					{ name: 'socket.io-client', var: 'io', path: 'dist/socket.io.js' },
					{ name: 'react', var: 'React', path: `umd/react.${reactMode}.js` },
					{ name: 'react-dom', var: 'ReactDOM', path: `umd/react-dom.${reactMode}.js` },
					{ name: 'react-router-dom', var: 'ReactRouterDOM', path: `umd/react-router-dom${min}.js` },
					{ name: 'react-markdown', var: 'ReactMarkdown', path: 'react-markdown.min.js' },
					{ name: 'antd', path: `dist/antd${min}.js`, style: `dist/antd${min}.css` },
					{ name: 'github-markdown-css', cssOnly: true, style: `github-markdown${min}.css` }
				],
				prodUrl: '//cdn.jsdelivr.net/npm/:name@:version/:path',
				prod: argv.mode === 'production',
				publicPath: '/node_modules'
			}),
			new MiniCssExtractPlugin({
				filename: '[name].[chunkhash:8].css'
			})
		],
		devtool: dev && 'inline-source-map',
		devServer: {
			historyApiFallback: true,
			proxy: {
				'/api': {
					secure: false,
					changeOrigin: true,
					target: `http://localhost:${config.get('port')}`
				},
				'/socket.io': {
					ws: true,
					secure: false,
					changeOrigin: true,
					target: `http://localhost:${config.get('port')}`
				}
			}
		},
		optimization: {
			minimize: argv.mode === 'production',
			minimizer: [new CssMinimizerPlugin(), '...']
		}
	}
}
<commit_msg>feat: choose no cdn<commit_after>const config = require('config')
const WebpackCdnPlugin = require('webpack-cdn-plugin')
const HtmlWebpackPlugin = require('html-webpack-plugin')
const MiniCssExtractPlugin = require('mini-css-extract-plugin')
const CssMinimizerPlugin = require('css-minimizer-webpack-plugin')
const packageJson = require('./package.json')

module.exports = (_env, argv) => {
	const dev = argv.mode === 'development'
	const reactMode = dev ? 'development' : 'production.min'
	const min = dev ? '' : '.min'

	return {
		entry: {
			app: './web'
		},
		output: {
			publicPath: '/',
			filename: '[name].[chunkhash:8].js'
		},
		module: {
			rules: [
				{
					test: /\.tsx?$/,
					loader: 'ts-loader'
				},
				{
					test: /\.(c|le)ss$/,
					use: [
						MiniCssExtractPlugin.loader,
						'css-loader',
						{
							loader: 'less-loader',
							options: {
								lessOptions: {
									javascriptEnabled: true
								}
							}
						}
					]
				}
			]
		},
		resolve: {
			extensions: ['.tsx', '.ts', '.js']
		},
		plugins: [
			new HtmlWebpackPlugin({
				title: 'DOJ',
				inject: 'body',
				favicon: 'web/logo.png',
				meta: {
					author: packageJson.author,
					description: packageJson.description,
					keywords: packageJson.keywords.join(',')
				}
			}),
			new WebpackCdnPlugin({
				modules: [
					{ name: 'moment', path: `min/moment.min.js` },
					{ name: 'axios', path: `dist/axios${min}.js` },
					{ name: 'ace-builds', var: 'ace', paths: [`src-min-noconflict/ace.js`, `src-min-noconflict/ext-static_highlight.js`] },
					{ name: 'katex', path: `dist/katex${min}.js`, style: `dist/katex${min}.css` },
					{ name: 'socket.io-client', var: 'io', path: 'dist/socket.io.js' },
					{ name: 'react', var: 'React', path: `umd/react.${reactMode}.js` },
					{ name: 'react-dom', var: 'ReactDOM', path: `umd/react-dom.${reactMode}.js` },
					{ name: 'react-router-dom', var: 'ReactRouterDOM', path: `umd/react-router-dom${min}.js` },
					{ name: 'react-markdown', var: 'ReactMarkdown', path: 'react-markdown.min.js' },
					{ name: 'antd', path: `dist/antd${min}.js`, style: `dist/antd${min}.css` },
					{ name: 'github-markdown-css', cssOnly: true, style: `github-markdown${min}.css` }
				],
				prodUrl: '//cdn.jsdelivr.net/npm/:name@:version/:path',
				// prodUrl: '/node_modules/:name/:path',
				prod: argv.mode === 'production',
				publicPath: '/node_modules'
			}),
			new MiniCssExtractPlugin({
				filename: '[name].[chunkhash:8].css'
			})
		],
		devtool: dev && 'inline-source-map',
		devServer: {
			historyApiFallback: true,
			proxy: {
				'/api': {
					secure: false,
					changeOrigin: true,
					target: `http://localhost:${config.get('port')}`
				},
				'/socket.io': {
					ws: true,
					secure: false,
					changeOrigin: true,
					target: `http://localhost:${config.get('port')}`
				}
			}
		},
		optimization: {
			minimize: argv.mode === 'production',
			minimizer: [new CssMinimizerPlugin(), '...']
		}
	}
}
<|endoftext|>


<commit_before>const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');

module.exports = {
  entry: './src/index.js',
  mode: 'production',
  plugins: [
    new HtmlWebpackPlugin({
    }),
  ],
  resolve: {
    modules: ['node_modules', 'src']
  },
  output: {
    filename: 'bundle.js',
    path: path.resolve(__dirname, 'dist'),
  },
  module: {
    rules: [
      {
        test: /\.s[ac]ss$/i,
        use: [
          "style-loader",
          "css-loader",
          {
            loader: "sass-loader",
            options: {
              // Prefer `dart-sass`
              implementation: require("sass"),
            },
          },
        ],
      },
    ],
  },
};
<commit_msg>Add favicon<commit_after>const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');

module.exports = {
  entry: './src/index.js',
  mode: 'production',
  plugins: [
    new HtmlWebpackPlugin({
      favicon: "./src/favicon.ico"
    }),
  ],
  resolve: {
    modules: ['node_modules', 'src']
  },
  output: {
    filename: 'bundle.js',
    path: path.resolve(__dirname, 'dist'),
  },
  module: {
    rules: [
      {
        test: /\.s[ac]ss$/i,
        use: [
          "style-loader",
          "css-loader",
          {
            loader: "sass-loader",
            options: {
              // Prefer `dart-sass`
              implementation: require("sass"),
            },
          },
        ],
      },
    ],
  },
};
<|endoftext|>


<commit_before>var fs               = require('fs'),
    util             = require('util'),
    utils            = require('./utils'),
    events           = require('events'),
    moments           = require('moment'),
    Playlist         = require('./api/Playlist'),
    Melted           = require('./api/Melted'),
    Media            = require('./api/Media'),
    ScheduledMedia   = require('./api/ScheduledMedia'),
    _                = require('underscore'),
    mvcp_server      = require('./drivers/mvcp/mvcp-driver');

function play( config ) {

    var self = this;

    self.mosto = config.mosto;
    self.server = config.mosto.server;
    self.status_driver = config.mosto.status_driver;

    self.synchronizer = undefined;
    self.fetcher = undefined;
    self.scheduler = undefined;

    /** PLAY MODULE */
    this.timer = null;
    this.timer_clock = moment();
    this.timer_relative_clock = null;
    this.timer_expected_clock = null;
    this.timer_difference = 0;

    this.sync_lock = false;
    this.sync_lock_start = 0;
    this.sync_lock_time = 0;
    this.sync_lock_diff = 0;

    this.actual_playing_clip = null;
    this.actual_playing_status = "";
    this.actual_playing_index = -1;
    this.previous_playing_index = -1;
    this.actual_playing_frame = -1;
    this.actual_playing_length = -1;
    this.actual_playing_fps = -1;
    this.actual_playing_progress = -1;
    this.actual_position_millis = 0;
    this.actual_expected_start = 0;
    this.previous_expected_start = 0;
    this.previous_position_millis = 0;
    this.ref_sched_index = 0;

    this.actual_status = null;

    this.full_status = undefined;
    this.prev_full_status = undefined;

    play.prototype.init = function() {
        self.fetcher = self.mosto.fetcher;
        self.scheduler = self.mosto.scheduler;
        self.synchronizer = self.mosto.synchronizer;
        if (self.synchronizer) self.synchronizer.on('play_downstream', function() {
            console.log("mbc-mosto: [INFO] [PLAY] received play_downstream from [SYNC]");
        });
    }

    play.prototype.sendStatus = function() {
        //real invocations.  This is just an example
        self.server.getServerStatus(function(resp1) {
            var status = resp1;
            self.server.getServerPlaylist(function(resp2) {
                var playlist = resp2;
                var st = self.buildStatus(playlist, status);
                self.emit("status", st);
            });
        });
    };

    play.prototype.buildStatus = function(serverPlaylist, serverStatus) {
        var status = {};
        var clip = {};
        var show = {};

        var currentPlaylistId = undefined;
        var prevPlaylistId    = undefined;
        var nextPlaylistId    = undefined;
        var currentClip       = undefined;
        var prevClip          = undefined;
        var nextClip          = undefined;

        if (serverStatus.actualClip !== undefined) {
            currentPlaylistId = serverStatus.actualClip.playlistId;
            if (self.fetcher.playlists!==undefined && self.fetcher.playlists.length>0) {
                // map the playlists list to their ids (converted to string)
                var index = _.chain(self.fetcher.playlists).map(function(playlist) {
                    return playlist.id.toString() }).indexOf(
                        serverStatus.actualClip.playlistId.toString() ).value();

                if (index >= 0)
                    currentPlaylistId = self.fetcher.playlists[index].id;
                if (index > 0)
                    prevPlaylistId = self.fetcher.playlists[index - 1].id;
                if (0<=index && index < (self.fetcher.playlists.length - 1))
                    nextPlaylistId = self.fetcher.playlists[index + 1].id;
            }
        }

        currentClip = serverStatus.actualClip;
        if (serverPlaylist!==undefined && serverPlaylist.length>0) {
            var currentClipOrder = parseInt(currentClip.order);
            if ( currentClipOrder > 0 ) {
                prevClip = _.find(serverPlaylist, function(walkClip) {
                    return (parseInt(walkClip.order) == (currentClipOrder - 1));
                });
            }
            if( currentClipOrder < (serverPlaylist.length - 1) ) {
                nextClip = _.find(serverPlaylist, function(walkClip) {
                    return (parseInt(walkClip.order) == (currentClipOrder + 1));
                });
            }
        }
        clip.previous = prevClip;
        clip.current  = currentClip;
        clip.next     = nextClip;

        show.previous = prevPlaylistId;
        show.current  = currentPlaylistId;
        show.next     = nextPlaylistId;

        status.clip     = clip;
        status.show     = show;
        status.position = serverStatus.currentPos;
        status.clips    = serverPlaylist;
        status.status   = serverStatus.status;

        return status;
    };

    play.prototype.statusHasChanged = function() {

        var result = ( self.prev_full_status == undefined );
        result = result || ( self.prev_full_status
                && ( self.prev_full_status.clips.length!=self.full_status.clips.length
                     || self.prev_full_status.clip.current!=self.full_status.clip.current
                     || self.prev_full_status.clip.prev!=self.full_status.clip.prev
                     || self.prev_full_status.clip.next!=self.full_status.clip.next

                     || self.prev_full_status.show.prev!=self.full_status.show.prev
                     || self.prev_full_status.show.current!=self.full_status.show.current
                     || self.prev_full_status.show.next!=self.full_status.show.next
                    )
                );
        return result;
    }

    /** PLAY MODULE*/
    /**
     *       start timer: not necessarelly frame accurate, interval: 200 ms
     *
     */

    play.prototype.timer_fun_status = function( actual_status ) {

        console.log("mbc-mosto: [INFO] [PLAY] timer_fun_status received.");

        self.previous_playing_index = self.actual_playing_index;

        self.actual_status = actual_status;

        self.actual_playing_status = self.actual_status.status;

        if (    self.actual_playing_status=="playing"
                || (self.actual_playing_status=="paused" && self.actual_status.actualClip.id=="black_id") ) {
            self.actual_playing_clip = self.actual_status.actualClip.id;
            self.actual_playing_index = self.actual_status.actualClip.order;
            self.actual_playing_progress = self.actual_status.currentPos;
            self.actual_playing_frame = self.actual_status.actualClip.currentFrame;
            self.actual_playing_length = self.actual_status.actualClip.totalFrames;
            self.actual_playing_fps =  self.actual_status.actualClip.fps;

            self.emit('statusclip', self.actual_status.actualClip);

            self.actual_position_millis = utils.convertFramesToMilliseconds( self.actual_status.actualClip.currentFrame, self.actual_status.actualClip.fps );
            self.actual_position_millis_length = self.actual_status.actualClip.totalFrames;

            self.emit('playing','playing clip: ' + self.actual_playing_clip );
        } else {
            self.actual_playing_frame = -1;
            self.actual_playing_index = -1;
            self.actual_position_millis = -1;
            self.actual_playing_clip = -1;
            self.actual_playing_progress = -1;
        }

        console.log("mbc-mosto: [INFO] [PLAY] timer_fun_status status: " + self.actual_playing_status + " clip: " + self.actual_playing_clip );

        self.server.getServerPlaylist( function( server_playing_list ) {

                self.prev_full_status = self.full_status;
                self.full_status = self.buildStatus( server_playing_list, self.actual_status );

                if ( self.statusHasChanged() ) {
                    self.emit('status', self.full_status );
                }

                //self.synchronizer.syncroScheduledClips( server_playing_list );
                console.log("mbc-mosto: [INFO] [PLAY] emitting sync_upstream");
                self.emit('sync_upstream', {
                    server_playlist: server_playing_list,
                    server_status: self.actual_status
                } );

            },
            function(error) {
                console.error("mbc-mosto: [ERROR] timer_fun_status >  getServerPlaylist() : " + error );
            }
        );

    }

    play.prototype.timerLock = function() {
        self.sync_lock = true;
    }

    play.prototype.timerUnlock = function() {
        self.sync_lock = false;
    }

    play.prototype.timerLocked = function() {
        return self.sync_lock;
    }

    play.prototype.upstreamActive = function() {
        return self.sync_lock;
    }

    play.prototype.timer_fun = function() {

        if (!self.sync_lock) {

            self.timerLock();

            //calculate now time...
            self.timer_clock = moment();
            self.sync_lock_start = moment();

            console.log("mbc-mosto: [INFO] [PLAY] timer_fun called: " + self.timer_clock.format("hh:mm:ss") );
            console.log("mbc-mosto: [INFO] [PLAY] time_window from: "  + self.fetcher.time_window_from.format("DD/MM/YYYY HH:mm:ss") + " to: " + self.fetcher.time_window_to.format("DD/MM/YYYY HH:mm:ss") );

            //get status
            self.server.getServerStatus( self.timer_fun_status, function( error ) { console.error("mbc-mosto: [ERROR] [PLAY] mosto.timer_fun > getServerStatus failed: " + error ); } );
        } else {
            self.sync_lock_time = moment();
            self.sync_lock_diff = self.sync_lock_time.diff(self.sync_lock_start);
            console.log("mbc-mosto: [INFO] sync LOCKED, for " + self.sync_lock_diff );
            if (Math.abs(self.sync_lock_diff)>200000) {
                //kill server and reconnect!!!
                self.mosto.server = null;
                self.mosto.server = new mvcp_server(self.mosto.config.mvcp_server);
                self.server = self.mosto.server;
                self.timerUnlock();
                self.stop();
                self.mosto.startMvcpServer(self.play);
            }
        }
    }

    play.prototype.play = function() {

        console.log("mbc-mosto: [INFO] Start playing mosto");

        if (!self.timer) {

            if (self.fetcher) {
                self.fetcher.updateTimeWindow();
                console.log("mbc-mosto: [INFO] [PLAY] setting window: from: "  + self.fetcher.time_window_from.format("DD/MM/YYYY HH:mm:ss") + " to: " + self.fetcher.time_window_to.format("DD/MM/YYYY HH:mm:ss") );
            }

            self.timer = setInterval( self.timer_fun, self.mosto.config.timer_interval );
            self.timer_fun();

            self.on('statusclip', function(stclip) {
                console.log("mbc-mosto: [INFO] [PLAY] emitting statusclip: " + stclip.currentFrame + " / "+  stclip.totalFrames);
                if (self.status_driver) self.status_driver.setStatusClip(stclip);
            });

            self.on('status', function(st) {
                console.log("mbc-mosto: [INFO] [PLAY] emitting status");
                if (self.status_driver) self.status_driver.setStatus(st);
            });

        }
    }

    play.prototype.stop = function() {
	    clearInterval(self.timer);
        self.timer = null;
    }

    play.prototype.pause = function() {}

};

exports = module.exports = function(config) {
    util.inherits(play, events.EventEmitter);
    var mosto_player = new play(config);
    return mosto_player;
};

<commit_msg>Parsing ints<commit_after>var fs               = require('fs'),
    util             = require('util'),
    utils            = require('./utils'),
    events           = require('events'),
    moments           = require('moment'),
    Playlist         = require('./api/Playlist'),
    Melted           = require('./api/Melted'),
    Media            = require('./api/Media'),
    ScheduledMedia   = require('./api/ScheduledMedia'),
    _                = require('underscore'),
    mvcp_server      = require('./drivers/mvcp/mvcp-driver');

function play( config ) {

    var self = this;

    self.mosto = config.mosto;
    self.server = config.mosto.server;
    self.status_driver = config.mosto.status_driver;

    self.synchronizer = undefined;
    self.fetcher = undefined;
    self.scheduler = undefined;

    /** PLAY MODULE */
    this.timer = null;
    this.timer_clock = moment();
    this.timer_relative_clock = null;
    this.timer_expected_clock = null;
    this.timer_difference = 0;

    this.sync_lock = false;
    this.sync_lock_start = 0;
    this.sync_lock_time = 0;
    this.sync_lock_diff = 0;

    this.actual_playing_clip = null;
    this.actual_playing_status = "";
    this.actual_playing_index = -1;
    this.previous_playing_index = -1;
    this.actual_playing_frame = -1;
    this.actual_playing_length = -1;
    this.actual_playing_fps = -1;
    this.actual_playing_progress = -1;
    this.actual_position_millis = 0;
    this.actual_expected_start = 0;
    this.previous_expected_start = 0;
    this.previous_position_millis = 0;
    this.ref_sched_index = 0;

    this.actual_status = null;

    this.full_status = undefined;
    this.prev_full_status = undefined;

    play.prototype.init = function() {
        self.fetcher = self.mosto.fetcher;
        self.scheduler = self.mosto.scheduler;
        self.synchronizer = self.mosto.synchronizer;
        if (self.synchronizer) self.synchronizer.on('play_downstream', function() {
            console.log("mbc-mosto: [INFO] [PLAY] received play_downstream from [SYNC]");
        });
    }

    play.prototype.sendStatus = function() {
        //real invocations.  This is just an example
        self.server.getServerStatus(function(resp1) {
            var status = resp1;
            self.server.getServerPlaylist(function(resp2) {
                var playlist = resp2;
                var st = self.buildStatus(playlist, status);
                self.emit("status", st);
            });
        });
    };

    play.prototype.buildStatus = function(serverPlaylist, serverStatus) {
        var status = {};
        var clip = {};
        var show = {};

        var currentPlaylistId = undefined;
        var prevPlaylistId    = undefined;
        var nextPlaylistId    = undefined;
        var currentClip       = undefined;
        var prevClip          = undefined;
        var nextClip          = undefined;

        if (serverStatus.actualClip !== undefined) {
            currentPlaylistId = serverStatus.actualClip.playlistId;
            if (self.fetcher.playlists!==undefined && self.fetcher.playlists.length>0) {
                // map the playlists list to their ids (converted to string)
                var index = _.chain(self.fetcher.playlists).map(function(playlist) {
                    return playlist.id.toString() }).indexOf(
                        serverStatus.actualClip.playlistId.toString() ).value();

                if (index >= 0)
                    currentPlaylistId = self.fetcher.playlists[index].id;
                if (index > 0)
                    prevPlaylistId = self.fetcher.playlists[index - 1].id;
                if (0<=index && index < (self.fetcher.playlists.length - 1))
                    nextPlaylistId = self.fetcher.playlists[index + 1].id;
            }
        }

        currentClip = serverStatus.actualClip;
        if (serverPlaylist!==undefined && serverPlaylist.length>0) {
            var currentClipOrder = parseInt(currentClip.order);
            if ( currentClipOrder > 0 ) {
                prevClip = _.find(serverPlaylist, function(walkClip) {
                    return (parseInt(walkClip.order) == (currentClipOrder - 1));
                });
            }
            if( currentClipOrder < (serverPlaylist.length - 1) ) {
                nextClip = _.find(serverPlaylist, function(walkClip) {
                    return (parseInt(walkClip.order) == (currentClipOrder + 1));
                });
            }
        }
        clip.previous = prevClip;
        clip.current  = currentClip;
        clip.next     = nextClip;

        show.previous = prevPlaylistId;
        show.current  = currentPlaylistId;
        show.next     = nextPlaylistId;

        status.clip     = clip;
        status.show     = show;
        status.position = serverStatus.currentPos;
        status.clips    = serverPlaylist;
        status.status   = serverStatus.status;

        return status;
    };

    play.prototype.statusHasChanged = function() {

        var result = ( self.prev_full_status == undefined );
        result = result || ( self.prev_full_status
                && ( self.prev_full_status.clips.length!=self.full_status.clips.length
                     || self.prev_full_status.clip.current!=self.full_status.clip.current
                     || self.prev_full_status.clip.prev!=self.full_status.clip.prev
                     || self.prev_full_status.clip.next!=self.full_status.clip.next

                     || self.prev_full_status.show.prev!=self.full_status.show.prev
                     || self.prev_full_status.show.current!=self.full_status.show.current
                     || self.prev_full_status.show.next!=self.full_status.show.next
                    )
                );
        return result;
    }

    /** PLAY MODULE*/
    /**
     *       start timer: not necessarelly frame accurate, interval: 200 ms
     *
     */

    play.prototype.timer_fun_status = function( actual_status ) {

        console.log("mbc-mosto: [INFO] [PLAY] timer_fun_status received.");

        self.previous_playing_index = self.actual_playing_index;

        self.actual_status = actual_status;

        self.actual_playing_status = self.actual_status.status;

        if (    self.actual_playing_status=="playing"
                || (self.actual_playing_status=="paused" && self.actual_status.actualClip.id=="black_id") ) {
            self.actual_playing_clip = self.actual_status.actualClip.id;
            self.actual_playing_index = parseInt(self.actual_status.actualClip.order);
            self.actual_playing_progress = self.actual_status.currentPos;
            self.actual_playing_frame = parseInt(self.actual_status.actualClip.currentFrame);
            self.actual_playing_length = parseInt(self.actual_status.actualClip.totalFrames);
            self.actual_playing_fps =  self.actual_status.actualClip.fps;

            self.emit('statusclip', self.actual_status.actualClip);

            self.actual_position_millis = utils.convertFramesToMilliseconds( self.actual_status.actualClip.currentFrame, self.actual_status.actualClip.fps );
            self.actual_position_millis_length = self.actual_status.actualClip.totalFrames;

            self.emit('playing','playing clip: ' + self.actual_playing_clip );
        } else {
            self.actual_playing_frame = -1;
            self.actual_playing_index = -1;
            self.actual_position_millis = -1;
            self.actual_playing_clip = -1;
            self.actual_playing_progress = -1;
        }

        console.log("mbc-mosto: [INFO] [PLAY] timer_fun_status status: " + self.actual_playing_status + " clip: " + self.actual_playing_clip );

        self.server.getServerPlaylist( function( server_playing_list ) {

                self.prev_full_status = self.full_status;
                self.full_status = self.buildStatus( server_playing_list, self.actual_status );

                if ( self.statusHasChanged() ) {
                    self.emit('status', self.full_status );
                }

                //self.synchronizer.syncroScheduledClips( server_playing_list );
                console.log("mbc-mosto: [INFO] [PLAY] emitting sync_upstream");
                self.emit('sync_upstream', {
                    server_playlist: server_playing_list,
                    server_status: self.actual_status
                } );

            },
            function(error) {
                console.error("mbc-mosto: [ERROR] timer_fun_status >  getServerPlaylist() : " + error );
            }
        );

    }

    play.prototype.timerLock = function() {
        self.sync_lock = true;
    }

    play.prototype.timerUnlock = function() {
        self.sync_lock = false;
    }

    play.prototype.timerLocked = function() {
        return self.sync_lock;
    }

    play.prototype.upstreamActive = function() {
        return self.sync_lock;
    }

    play.prototype.timer_fun = function() {

        if (!self.sync_lock) {

            self.timerLock();

            //calculate now time...
            self.timer_clock = moment();
            self.sync_lock_start = moment();

            console.log("mbc-mosto: [INFO] [PLAY] timer_fun called: " + self.timer_clock.format("hh:mm:ss") );
            console.log("mbc-mosto: [INFO] [PLAY] time_window from: "  + self.fetcher.time_window_from.format("DD/MM/YYYY HH:mm:ss") + " to: " + self.fetcher.time_window_to.format("DD/MM/YYYY HH:mm:ss") );

            //get status
            self.server.getServerStatus( self.timer_fun_status, function( error ) { console.error("mbc-mosto: [ERROR] [PLAY] mosto.timer_fun > getServerStatus failed: " + error ); } );
        } else {
            self.sync_lock_time = moment();
            self.sync_lock_diff = self.sync_lock_time.diff(self.sync_lock_start);
            console.log("mbc-mosto: [INFO] sync LOCKED, for " + self.sync_lock_diff );
            if (Math.abs(self.sync_lock_diff)>200000) {
                //kill server and reconnect!!!
                self.mosto.server = null;
                self.mosto.server = new mvcp_server(self.mosto.config.mvcp_server);
                self.server = self.mosto.server;
                self.timerUnlock();
                self.stop();
                self.mosto.startMvcpServer(self.play);
            }
        }
    }

    play.prototype.play = function() {

        console.log("mbc-mosto: [INFO] Start playing mosto");

        if (!self.timer) {

            if (self.fetcher) {
                self.fetcher.updateTimeWindow();
                console.log("mbc-mosto: [INFO] [PLAY] setting window: from: "  + self.fetcher.time_window_from.format("DD/MM/YYYY HH:mm:ss") + " to: " + self.fetcher.time_window_to.format("DD/MM/YYYY HH:mm:ss") );
            }

            self.timer = setInterval( self.timer_fun, self.mosto.config.timer_interval );
            self.timer_fun();

            self.on('statusclip', function(stclip) {
                console.log("mbc-mosto: [INFO] [PLAY] emitting statusclip: " + stclip.currentFrame + " / "+  stclip.totalFrames);
                if (self.status_driver) self.status_driver.setStatusClip(stclip);
            });

            self.on('status', function(st) {
                console.log("mbc-mosto: [INFO] [PLAY] emitting status");
                if (self.status_driver) self.status_driver.setStatus(st);
            });

        }
    }

    play.prototype.stop = function() {
	    clearInterval(self.timer);
        self.timer = null;
    }

    play.prototype.pause = function() {}

};

exports = module.exports = function(config) {
    util.inherits(play, events.EventEmitter);
    var mosto_player = new play(config);
    return mosto_player;
};

<|endoftext|>


<commit_before>'use strict';

const deepcopy = require('deepcopy'),
      webpack = require('webpack');

const ExtractTextPlugin = require('extract-text-webpack-plugin');

// eslint-disable-next-line no-unused-vars
module.exports = function(env) {
  const baseConfig = {
    context: __dirname,
  };

  return [
    Object.assign({}, deepcopy(baseConfig), {
      entry: {
        'manifest': `${__dirname}/src/manifest.js`
      },
      module: {
        rules: [
          {
            exclude: /node_modules/,
            test: /manifest\.js$/,
            use: ExtractTextPlugin.extract({
              use: [
                { loader: 'raw-loader' },
                { loader: 'val-loader' },
              ],
            }),
          },
        ],
      },
      output: {
        filename: '[name].json',
        path: `${__dirname}/ext/`,
        publicPath: './',
      },
      plugins: [
        new ExtractTextPlugin('manifest.json'),
      ],
    }),
    Object.assign({}, deepcopy(baseConfig), {
      entry: {
        'background': `${__dirname}/src/background.js`,
        'options': `${__dirname}/src/options.js`,
        'vendor': [
          'mustache',
          'sprintf-js',
        ],
      },
      module: {
        rules: [
          {
            exclude: /node_modules/,
            include: /options\.js/,
            test: /\.js$/,
            use: [
              { loader: 'babel-loader' },
            ],
          },
        ],
      },
      output: {
        chunkFilename: 'chunk-[id]-[hash].js',
        filename: '[name].js',
        path: `${__dirname}/ext/`,
        publicPath: './',
      },
      target: 'web',
      plugins: [
        new webpack.optimize.CommonsChunkPlugin({
          name: 'vendor',
          minChunks: Infinity,
        }),
        new webpack.BannerPlugin({
          banner: [
            '@license Copyright(c) 2017 sasa+1',
            'https://github.com/chocolateorange/new-post.crx',
            'Released under the MIT license.',
          ].join('\n'),
          entryOnly: true,
          raw: false,
        }),
      ],
    }),
  ];
};
<commit_msg>added loaders for css<commit_after>'use strict';

const deepcopy = require('deepcopy'),
      webpack = require('webpack');

const ExtractTextPlugin = require('extract-text-webpack-plugin');

// eslint-disable-next-line no-unused-vars
module.exports = function(env) {
  const baseConfig = {
    context: __dirname,
  };

  return [
    Object.assign({}, deepcopy(baseConfig), {
      entry: {
        'manifest': `${__dirname}/src/manifest.js`
      },
      module: {
        rules: [
          {
            exclude: /node_modules/,
            test: /manifest\.js$/,
            use: ExtractTextPlugin.extract({
              use: [
                { loader: 'raw-loader' },
                { loader: 'val-loader' },
              ],
            }),
          },
        ],
      },
      output: {
        filename: '[name].json',
        path: `${__dirname}/ext/`,
        publicPath: './',
      },
      plugins: [
        new ExtractTextPlugin('manifest.json'),
      ],
    }),
    Object.assign({}, deepcopy(baseConfig), {
      entry: {
        'background': `${__dirname}/src/background.js`,
        'options': `${__dirname}/src/options.js`,
        'vendor': [
          'mustache',
          'sprintf-js',
        ],
      },
      module: {
        rules: [
          {
            exclude: /node_modules/,
            include: /options\.js/,
            test: /\.js$/,
            use: [
              { loader: 'babel-loader' },
            ],
          },
          {
            exclude: /node_modules/,
            test: /\.css$/,
            use: [
              { loader: 'style-loader' },
              { loader: 'css-loader'   },
            ],
          },
        ],
      },
      output: {
        chunkFilename: 'chunk-[id]-[hash].js',
        filename: '[name].js',
        path: `${__dirname}/ext/`,
        publicPath: './',
      },
      target: 'web',
      plugins: [
        new webpack.optimize.CommonsChunkPlugin({
          name: 'vendor',
          minChunks: Infinity,
        }),
        new webpack.BannerPlugin({
          banner: [
            '@license Copyright(c) 2017 sasa+1',
            'https://github.com/chocolateorange/new-post.crx',
            'Released under the MIT license.',
          ].join('\n'),
          entryOnly: true,
          raw: false,
        }),
      ],
    }),
  ];
};
<|endoftext|>


<commit_before>const path = require('path')

module.exports = {
  entry: './docs/App.jsx',
  output: {
    filename: './docs/bundle.js'
  },
  devServer: {
    inline: true,
    contentBase: path.join(__dirname, 'docs'),
  },
  module: {
    rules: [{
      test: /\.jsx?$/,
      exclude: /node_modules/,
      loader: 'babel-loader'
    }]
  },
  devtool: 'source-map'
}
<commit_msg>Remove trailing comma. Thanks standardjs 😤<commit_after>const path = require('path')

module.exports = {
  entry: './docs/App.jsx',
  output: {
    filename: './docs/bundle.js'
  },
  devServer: {
    inline: true,
    contentBase: path.join(__dirname, 'docs')
  },
  module: {
    rules: [{
      test: /\.jsx?$/,
      exclude: /node_modules/,
      loader: 'babel-loader'
    }]
  },
  devtool: 'source-map'
}
<|endoftext|>


<commit_before>const process = require('process');
const path = require('path');
const webpack = require('webpack');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const marked = require('marked');
const WebpackPwaManifest = require('webpack-pwa-manifest');
const CssMinimizerPlugin = require('css-minimizer-webpack-plugin');
const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin');
const cssnano = require('cssnano');

const skMessages = require('./src/translations/sk-shared.json');
const csMessages = require('./src/translations/cs-shared.json');
const enMessages = require('./src/translations/en-shared.json');
const huMessages = require('./src/translations/hu-shared.json');

const prod = process.env.DEPLOYMENT && process.env.DEPLOYMENT !== 'dev';

const fastDev = !prod && !process.env.DISABLE_FAST_DEV;

const renderer = new marked.Renderer();

renderer.link = (href, title, text) =>
  `<a href="${href}" title="${title ?? ''}">${text}</a>`;

const htmlPluginProps = {
  filename: 'index.html',
  template: 'index.ejs',
  inject: false,
  templateParameters: {
    lang: 'en',
    title: enMessages.title,
    description: enMessages.description,
    errorHtml:
      '
Problem starting application
' +
      '
Please make sure you are using recent version of a modern browser (Google Chrome, Firefox, Safari, Opera, Edge, Chromium, Vivaldi, Brave, …).
',
    nojsMessage:
      'JavaScript enabled browser is required to run this application.',
    loadingMessage: 'Loading…',
  },
};

module.exports = {
  mode: prod ? 'production' : 'development',
  context: path.resolve(__dirname, 'src'),
  entry: './index.tsx',
  output: {
    filename: '[name].[chunkhash].js',
    chunkFilename: '[name].[chunkhash].js',
    path: path.resolve(__dirname, 'dist'),
  },
  resolve: {
    extensions: ['.ts', '.tsx', '.js', '.jsx'],
    alias: {
      fm3: path.resolve(__dirname, 'src'),
      pica: 'pica/dist/pica.js',
    },
    fallback: {
      util: require.resolve('util/'), // for typescript-is avter upgrading webpack from 4 to 5
    },
  },
  optimization: {
    // moduleIds: 'deterministic',
    minimizer: ['...', new CssMinimizerPlugin()],
  },
  // more info: https://webpack.js.org/configuration/devtool/
  devtool: prod ? 'source-map' : 'cheap-module-source-map',
  module: {
    rules: [
      // see https://github.com/Leaflet/Leaflet/issues/7403
      {
        enforce: 'pre',
        test: /\bnode_modules\/leaflet\/dist\/leaflet-src\.js/,
        loader: 'string-replace-loader',
        options: {
          search: '(win && chrome) ? 2 * window.devicePixelRatio :',
          replace:
            "(win && chrome) ? 2 * window.devicePixelRatio : (navigator.platform.indexOf('Linux') === 0 && chrome) ? window.devicePixelRatio :",
          strict: true,
        },
      },
      {
        // babelify some too modern libraries
        test: /\bnode_modules\/.*\/?(exifreader|strict-uri-encode|query-string|split-on-first|leaflet|@?react-leaflet)\/.*\.js$/,
        loader: 'babel-loader',
        options: {
          presets: [
            [
              '@babel/preset-env',
              {
                targets: {
                  browsers: ['> 0.5%'],
                },
              },
            ],
          ],
        },
      },
      {
        test: /\.(t|j)sx?$/,
        exclude: /node_modules/,
        use: {
          loader: 'ts-loader',
          options: {
            compiler: 'ttypescript', // this is for typescript-is
            transpileOnly: fastDev,
          },
        },
      },
      {
        test: /\.(png|svg|jpg|jpeg|gif|woff|ttf|eot|woff2)$/,
        type: 'asset/resource',
      },
      {
        test: /\.scss$/,
        use: [
          prod
            ? {
                loader: MiniCssExtractPlugin.loader,
                options: {
                  publicPath: (resourcePath, context) => {
                    return (
                      path.relative(path.dirname(resourcePath), context) + '/'
                    );
                  },
                },
              }
            : 'style-loader',
          'css-loader',
          'sass-loader',
        ],
      },
      {
        test: /\.overpass$/,
        loader: '../overpass-loader',
      },
      {
        test: /\.css$/,
        use: [
          prod
            ? {
                loader: MiniCssExtractPlugin.loader,
                options: {
                  publicPath: (resourcePath, context) => {
                    return (
                      path.relative(path.dirname(resourcePath), context) + '/'
                    );
                  },
                },
              }
            : 'style-loader',
          'css-loader',
        ],
      },
      {
        test: /\.md$/,
        use: [
          {
            loader: 'html-loader',
          },
          {
            loader: 'markdown-loader',
            options: {
              renderer,
            },
          },
        ],
      },
      {
        test: /\.mjs$/,
        include: /node_modules/,
        type: 'javascript/auto',
      },
    ],
  },
  plugins: [
    new ForkTsCheckerWebpackPlugin({
      eslint: {
        enabled: !fastDev,
        files: './**/*.{ts,tsx,js,jsx}',
      },
      typescript: {
        configFile: path.resolve(__dirname, './tsconfig.json'),
      },
      async: fastDev,
    }),
    new webpack.EnvironmentPlugin({
      ...(prod ? { NODE_ENV: 'production' } : null), // for react
      BROWSER: true,
      DEPLOYMENT: process.env.DEPLOYMENT ?? null,
      FM_MAPSERVER_URL:
        process.env.FM_MAPSERVER_URL || 'https://outdoor.tiles.freemap.sk',
      MAX_GPX_TRACK_SIZE_IN_MB: 15,
      BASE_URL:
        {
          www: 'https://www.freemap.sk',
          next: 'https://next.freemap.sk',
        }[process.env.DEPLOYMENT] || 'https://local.freemap.sk:9000',
      API_URL:
        {
          www: 'https://backend.freemap.sk',
          next: 'https://backend.freemap.sk',
        }[process.env.DEPLOYMENT] || 'https://local.freemap.sk:3000',
      GA_MEASUREMENT_ID:
        { www: 'UA-89861822-3', next: 'UA-89861822-4' }[
          process.env.DEPLOYMENT
        ] || null,
      FB_APP_ID:
        { www: '681854635902254', next: '681854635902254' }[
          process.env.DEPLOYMENT
        ] || null,
      ROVAS_URL_PREFIX:
        {
          www: 'https://rovas.app/rewpro?paytype=project&recipient=35384',
          next: 'https://rovas.app/rewpro?paytype=project&recipient=35384',
        }[process.env.DEPLOYMENT] ||
        'https://dev.merit.world/rewpro?paytype=project&recipient=24130',
    }),
    new CleanWebpackPlugin(),
    new HtmlWebpackPlugin(htmlPluginProps), // fallback for dev
    new HtmlWebpackPlugin({
      ...htmlPluginProps,
      filename: 'index-en.html',
    }),
    new HtmlWebpackPlugin({
      ...htmlPluginProps,
      filename: 'index-sk.html',
      templateParameters: {
        lang: 'sk',
        title: skMessages.title,
        description: skMessages.description,
        errorHtml:
          '
Aplikáciu sa nepodarilo spustiť
' +
          '
Uistite sa, že používate aktuálnu verziu niektorého zo súčasných prehliadačov (Google Chrome, Firefox, Safari, Opera, Edge, Chromium, Vivaldi, Brave, …).
',
        nojsMessage:
          'Aplikácia vyžaduje prehliadač so zapnutou podporou JavaScriptu.',
        loadingMessage: 'Načítavam…',
      },
    }),
    new HtmlWebpackPlugin({
      ...htmlPluginProps,
      filename: 'index-cs.html',
      templateParameters: {
        lang: 'cs',
        title: csMessages.title,
        description: csMessages.description,
        errorHtml:
          '
Aplikaci se nepodařilo spustit
' +
          '
Ujistěte se, že používáte aktuální verzi některého ze současných prohlížečů (Google Chrome, Firefox, Safari, Opera, Edge, Chromium, Vivaldi, Brave, …).
',
        nojsMessage:
          'Aplikace vyžaduje prohlížeč se zapnutou podporou JavaScriptu.',
        loadingMessage: 'Načítám…',
      },
    }),
    new HtmlWebpackPlugin({
      ...htmlPluginProps,
      filename: 'index-hu.html',
      templateParameters: {
        lang: 'hu',
        title: huMessages.title,
        description: huMessages.description,
        errorHtml:
          '
Hiba történt az alkalmazás elindításánál
' +
          '
Győződjék meg arról, hogy egy modern böngésző (Google Chrome, Firefox, Safari, Opera, Edge, Chromium, Vivaldi, Brave, …) friss verzióját használja.
',
        nojsMessage:
          'Az alkalmazás futtatásához JavaScriptet támogató böngészőre van szükség.',
        loadingMessage: 'Loading…', // TODO translate
      },
    }),
    new WebpackPwaManifest({
      inject: true,
      ios: true,
      publicPath: '/',
      name: 'Freemap Slovakia',
      short_name: 'Freemap',
      description:
        'Freemap je voľne dostupná online mapa Slovenska založená na dátach z OpenStreetMap',
      background_color: '#ffffff',
      theme_color: '#ffffff',
      'theme-color': '#ffffff',
      display: 'standalone',
      dir: 'auto',
      icons: [
        {
          src: path.resolve('src/images/freemap-logo-small.png'),
          sizes: [96, 128, 192, 256, 384, 512], // multiple sizes
        },
      ],
      orientation: 'any',
      share_target: {
        action: '/',
        method: 'POST',
        enctype: 'multipart/form-data',
        params: {
          title: 'title',
          text: 'text',
          url: 'url',
          files: [
            {
              name: 'file',
              accept: ['image/jpeg', 'application/gpx+xml'],
            },
          ],
        },
      },
    }),
    new CopyWebpackPlugin({
      patterns: [
        {
          from: 'static/**/*',
          to: '[name][ext]',
          globOptions: { dot: true },
        },
      ],
    }),
    prod &&
      new MiniCssExtractPlugin({
        // Options similar to the same options in webpackOptions.output
        // both options are optional
        filename: '[name].[chunkhash].css',
        chunkFilename: '[name].[chunkhash].css',
      }),
    new webpack.ContextReplacementPlugin(
      /intl\/locale-data\/jsonp$/,
      /(sk|cs|en)\.tsx/,
    ),
  ].filter((x) => x),
  devServer: {
    allowedHosts: 'all',
  },
};
<commit_msg>fixed scroll-zooming on linux FF 92<commit_after>const process = require('process');
const path = require('path');
const webpack = require('webpack');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const marked = require('marked');
const WebpackPwaManifest = require('webpack-pwa-manifest');
const CssMinimizerPlugin = require('css-minimizer-webpack-plugin');
const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin');
const cssnano = require('cssnano');

const skMessages = require('./src/translations/sk-shared.json');
const csMessages = require('./src/translations/cs-shared.json');
const enMessages = require('./src/translations/en-shared.json');
const huMessages = require('./src/translations/hu-shared.json');

const prod = process.env.DEPLOYMENT && process.env.DEPLOYMENT !== 'dev';

const fastDev = !prod && !process.env.DISABLE_FAST_DEV;

const renderer = new marked.Renderer();

renderer.link = (href, title, text) =>
  `<a href="${href}" title="${title ?? ''}">${text}</a>`;

const htmlPluginProps = {
  filename: 'index.html',
  template: 'index.ejs',
  inject: false,
  templateParameters: {
    lang: 'en',
    title: enMessages.title,
    description: enMessages.description,
    errorHtml:
      '
Problem starting application
' +
      '
Please make sure you are using recent version of a modern browser (Google Chrome, Firefox, Safari, Opera, Edge, Chromium, Vivaldi, Brave, …).
',
    nojsMessage:
      'JavaScript enabled browser is required to run this application.',
    loadingMessage: 'Loading…',
  },
};

module.exports = {
  mode: prod ? 'production' : 'development',
  context: path.resolve(__dirname, 'src'),
  entry: './index.tsx',
  output: {
    filename: '[name].[chunkhash].js',
    chunkFilename: '[name].[chunkhash].js',
    path: path.resolve(__dirname, 'dist'),
  },
  resolve: {
    extensions: ['.ts', '.tsx', '.js', '.jsx'],
    alias: {
      fm3: path.resolve(__dirname, 'src'),
      pica: 'pica/dist/pica.js',
    },
    fallback: {
      util: require.resolve('util/'), // for typescript-is avter upgrading webpack from 4 to 5
    },
  },
  optimization: {
    // moduleIds: 'deterministic',
    minimizer: ['...', new CssMinimizerPlugin()],
  },
  // more info: https://webpack.js.org/configuration/devtool/
  devtool: prod ? 'source-map' : 'cheap-module-source-map',
  module: {
    rules: [
      // see https://github.com/Leaflet/Leaflet/issues/7403
      {
        enforce: 'pre',
        test: /\bnode_modules\/leaflet\/dist\/leaflet-src\.js/,
        loader: 'string-replace-loader',
        options: {
          search: '(win && chrome) ? 2 * window.devicePixelRatio :',
          replace:
            "(win && chrome || navigator.platform.indexOf('Linux') === 0) ? 2 * window.devicePixelRatio :",
          strict: true,
        },
      },
      {
        // babelify some too modern libraries
        test: /\bnode_modules\/.*\/?(exifreader|strict-uri-encode|query-string|split-on-first|leaflet|@?react-leaflet)\/.*\.js$/,
        loader: 'babel-loader',
        options: {
          presets: [
            [
              '@babel/preset-env',
              {
                targets: {
                  browsers: ['> 0.5%'],
                },
              },
            ],
          ],
        },
      },
      {
        test: /\.(t|j)sx?$/,
        exclude: /node_modules/,
        use: {
          loader: 'ts-loader',
          options: {
            compiler: 'ttypescript', // this is for typescript-is
            transpileOnly: fastDev,
          },
        },
      },
      {
        test: /\.(png|svg|jpg|jpeg|gif|woff|ttf|eot|woff2)$/,
        type: 'asset/resource',
      },
      {
        test: /\.scss$/,
        use: [
          prod
            ? {
                loader: MiniCssExtractPlugin.loader,
                options: {
                  publicPath: (resourcePath, context) => {
                    return (
                      path.relative(path.dirname(resourcePath), context) + '/'
                    );
                  },
                },
              }
            : 'style-loader',
          'css-loader',
          'sass-loader',
        ],
      },
      {
        test: /\.overpass$/,
        loader: '../overpass-loader',
      },
      {
        test: /\.css$/,
        use: [
          prod
            ? {
                loader: MiniCssExtractPlugin.loader,
                options: {
                  publicPath: (resourcePath, context) => {
                    return (
                      path.relative(path.dirname(resourcePath), context) + '/'
                    );
                  },
                },
              }
            : 'style-loader',
          'css-loader',
        ],
      },
      {
        test: /\.md$/,
        use: [
          {
            loader: 'html-loader',
          },
          {
            loader: 'markdown-loader',
            options: {
              renderer,
            },
          },
        ],
      },
      {
        test: /\.mjs$/,
        include: /node_modules/,
        type: 'javascript/auto',
      },
    ],
  },
  plugins: [
    new ForkTsCheckerWebpackPlugin({
      eslint: {
        enabled: !fastDev,
        files: './**/*.{ts,tsx,js,jsx}',
      },
      typescript: {
        configFile: path.resolve(__dirname, './tsconfig.json'),
      },
      async: fastDev,
    }),
    new webpack.EnvironmentPlugin({
      ...(prod ? { NODE_ENV: 'production' } : null), // for react
      BROWSER: true,
      DEPLOYMENT: process.env.DEPLOYMENT ?? null,
      FM_MAPSERVER_URL:
        process.env.FM_MAPSERVER_URL || 'https://outdoor.tiles.freemap.sk',
      MAX_GPX_TRACK_SIZE_IN_MB: 15,
      BASE_URL:
        {
          www: 'https://www.freemap.sk',
          next: 'https://next.freemap.sk',
        }[process.env.DEPLOYMENT] || 'https://local.freemap.sk:9000',
      API_URL:
        {
          www: 'https://backend.freemap.sk',
          next: 'https://backend.freemap.sk',
        }[process.env.DEPLOYMENT] || 'https://local.freemap.sk:3000',
      GA_MEASUREMENT_ID:
        { www: 'UA-89861822-3', next: 'UA-89861822-4' }[
          process.env.DEPLOYMENT
        ] || null,
      FB_APP_ID:
        { www: '681854635902254', next: '681854635902254' }[
          process.env.DEPLOYMENT
        ] || null,
      ROVAS_URL_PREFIX:
        {
          www: 'https://rovas.app/rewpro?paytype=project&recipient=35384',
          next: 'https://rovas.app/rewpro?paytype=project&recipient=35384',
        }[process.env.DEPLOYMENT] ||
        'https://dev.merit.world/rewpro?paytype=project&recipient=24130',
    }),
    new CleanWebpackPlugin(),
    new HtmlWebpackPlugin(htmlPluginProps), // fallback for dev
    new HtmlWebpackPlugin({
      ...htmlPluginProps,
      filename: 'index-en.html',
    }),
    new HtmlWebpackPlugin({
      ...htmlPluginProps,
      filename: 'index-sk.html',
      templateParameters: {
        lang: 'sk',
        title: skMessages.title,
        description: skMessages.description,
        errorHtml:
          '
Aplikáciu sa nepodarilo spustiť
' +
          '
Uistite sa, že používate aktuálnu verziu niektorého zo súčasných prehliadačov (Google Chrome, Firefox, Safari, Opera, Edge, Chromium, Vivaldi, Brave, …).
',
        nojsMessage:
          'Aplikácia vyžaduje prehliadač so zapnutou podporou JavaScriptu.',
        loadingMessage: 'Načítavam…',
      },
    }),
    new HtmlWebpackPlugin({
      ...htmlPluginProps,
      filename: 'index-cs.html',
      templateParameters: {
        lang: 'cs',
        title: csMessages.title,
        description: csMessages.description,
        errorHtml:
          '
Aplikaci se nepodařilo spustit
' +
          '
Ujistěte se, že používáte aktuální verzi některého ze současných prohlížečů (Google Chrome, Firefox, Safari, Opera, Edge, Chromium, Vivaldi, Brave, …).
',
        nojsMessage:
          'Aplikace vyžaduje prohlížeč se zapnutou podporou JavaScriptu.',
        loadingMessage: 'Načítám…',
      },
    }),
    new HtmlWebpackPlugin({
      ...htmlPluginProps,
      filename: 'index-hu.html',
      templateParameters: {
        lang: 'hu',
        title: huMessages.title,
        description: huMessages.description,
        errorHtml:
          '
Hiba történt az alkalmazás elindításánál
' +
          '
Győződjék meg arról, hogy egy modern böngésző (Google Chrome, Firefox, Safari, Opera, Edge, Chromium, Vivaldi, Brave, …) friss verzióját használja.
',
        nojsMessage:
          'Az alkalmazás futtatásához JavaScriptet támogató böngészőre van szükség.',
        loadingMessage: 'Loading…', // TODO translate
      },
    }),
    new WebpackPwaManifest({
      inject: true,
      ios: true,
      publicPath: '/',
      name: 'Freemap Slovakia',
      short_name: 'Freemap',
      description:
        'Freemap je voľne dostupná online mapa Slovenska založená na dátach z OpenStreetMap',
      background_color: '#ffffff',
      theme_color: '#ffffff',
      'theme-color': '#ffffff',
      display: 'standalone',
      dir: 'auto',
      icons: [
        {
          src: path.resolve('src/images/freemap-logo-small.png'),
          sizes: [96, 128, 192, 256, 384, 512], // multiple sizes
        },
      ],
      orientation: 'any',
      share_target: {
        action: '/',
        method: 'POST',
        enctype: 'multipart/form-data',
        params: {
          title: 'title',
          text: 'text',
          url: 'url',
          files: [
            {
              name: 'file',
              accept: ['image/jpeg', 'application/gpx+xml'],
            },
          ],
        },
      },
    }),
    new CopyWebpackPlugin({
      patterns: [
        {
          from: 'static/**/*',
          to: '[name][ext]',
          globOptions: { dot: true },
        },
      ],
    }),
    prod &&
      new MiniCssExtractPlugin({
        // Options similar to the same options in webpackOptions.output
        // both options are optional
        filename: '[name].[chunkhash].css',
        chunkFilename: '[name].[chunkhash].css',
      }),
    new webpack.ContextReplacementPlugin(
      /intl\/locale-data\/jsonp$/,
      /(sk|cs|en)\.tsx/,
    ),
  ].filter((x) => x),
  devServer: {
    allowedHosts: 'all',
  },
};
<|endoftext|>


<commit_before>var config = {
  entry: './main.js',

  output: {
    path: './',
    publicPath: './',
    filename: './index.js',
  },

  devServer: {
    inline: true,
    port: 3000
  },

  module: {
    loaders: [{
      test: /\.jsx?$/,
      exclude: /node_modules/,
      loader: 'babel',
      query: {
        presets: ['es2015', 'react']
      }
    }, {
      test: /\.css$/,
      loader: "style-loader!css-loader"
    }, {
      test: /\.scss$/,
      loaders: ["style-loader", "css-loader", "sass-loader"]
    }, {
      test: /\.(png|jpg|gif)$/,
      loader: 'url-loader?limit=100000'
    }, {
      test: /\.(ttf|otf|eot|svg|woff(2)?)(\?[a-z0-9]+)?$/,
      loader: 'file-loader?name=fonts/[name].[ext]'
    }]
  },
  resolve: {
    extensions: ['', '.js', '.jsx']
  }
}

module.exports = config;<commit_msg>build update<commit_after>var config = {
  entry: './main.js',

  output: {
    path: '/',
    publicPath: '/',
    filename: 'index.js',
  },

  devServer: {
    inline: true,
    port: 3000
  },

  module: {
    loaders: [{
      test: /\.jsx?$/,
      exclude: /node_modules/,
      loader: 'babel',
      query: {
        presets: ['es2015', 'react']
      }
    }, {
      test: /\.css$/,
      loader: "style-loader!css-loader"
    }, {
      test: /\.scss$/,
      loaders: ["style-loader", "css-loader", "sass-loader"]
    }, {
      test: /\.(png|jpg|gif)$/,
      loader: 'url-loader?limit=100000'
    }, {
      test: /\.(ttf|otf|eot|svg|woff(2)?)(\?[a-z0-9]+)?$/,
      loader: 'file-loader?name=fonts/[name].[ext]'
    }]
  }
}

module.exports = config;<|endoftext|>


<commit_before>
const webpack = require('webpack');

module.exports = {
  entry: [
    './src/index.js'
  ],
  devtool: 'eval',
  output: {
    path: __dirname,
    publicPath: '/',
    filename: 'bundle.js'
  },

  plugins: [
    new webpack.optimize.OccurenceOrderPlugin(),
    new webpack.DefinePlugin({
      'process.env': {
        NODE_ENV: JSON.stringify('production')
      }
    }),
    new webpack.optimize.UglifyJsPlugin({
      compressor: {
        warnings: false
      }
    })
  ],

  module: {
    loaders: [{
      exclude: /node_modules/,
      loader: 'babel-loader',
      query: {
        presets: ['react', 'es2015', 'stage-2'],
        plugins: ['transform-runtime', 'transform-async-to-generator']
      }
    }]
  },
  resolve: {
    extensions: ['', '.js', '.jsx']
  },
  devServer: {
    historyApiFallback: true,
    contentBase: './'
  }
};
<commit_msg>new file update<commit_after>
const webpack = require('webpack');

module.exports = {
  entry: [
    './src/index.js'
  ],
  devtool: 'source-map',
  output: {
    path: __dirname,
    publicPath: '/',
    filename: 'bundle.js'
  },

  plugins: [
    new webpack.optimize.OccurenceOrderPlugin(),
    new webpack.DefinePlugin({
      'process.env': {
        NODE_ENV: JSON.stringify('production')
      }
    }),
    new webpack.optimize.UglifyJsPlugin({
      compressor: {
        warnings: false
      }
    })
  ],

  module: {
    loaders: [{
      exclude: /node_modules/,
      loader: 'babel-loader',
      query: {
        presets: ['react', 'es2015', 'stage-2'],
        plugins: ['transform-runtime', 'transform-async-to-generator']
      }
    }]
  },
  resolve: {
    extensions: ['', '.js', '.jsx']
  },
  devServer: {
    historyApiFallback: true,
    contentBase: './'
  }
};
<|endoftext|>


<commit_before>var path = require('path');
var util = require('util');
// var autoprefixer = require('autoprefixer');
var pkg = require('../package.json');

var loaders = require('./loaders');
var plugins = require('./plugins');

var DEBUG = process.env.NODE_ENV === 'development';
var TEST = process.env.NODE_ENV === 'test';

var jsBundle = path.join('js', '[name].js');

var entry = {
  app: ['./app.js']
};

// if (DEBUG) {
//   entry.app.push(
//     util.format(
//       'webpack-dev-server/client?http://%s:%d',
//       pkg.config.devHost,
//       pkg.config.devPort
//     )
//   );
//   entry.app.push('webpack/hot/dev-server');
// }

var context = path.join(__dirname, '../resources/assets');
var config = {
  context: context,
  cache: DEBUG,
  debug: DEBUG,
  target: 'web',
  devtool: DEBUG || TEST ? 'inline-source-map' : 'source-map',
  entry: entry,
  output: {
    path: path.resolve(pkg.config.buildDir),
    publicPath: '/',
    filename: jsBundle,
    pathinfo: false
  },
  module: {
    loaders: loaders
  },
  // postcss: [
  //   autoprefixer
  // ],
  plugins: plugins,
  resolve: {
    extensions: ['', '.js', '.json', '.jsx'],
    alias: {
      'decorators': path.join(context, 'decorators'),
      'components': path.join(context, 'components'),
      'reducers': path.join(context, 'reducers'),
      'actions': path.join(context, 'actions'),
      'constants': path.join(context, 'constants'),
      'utils': path.join(context, 'utils'),
      'lib': path.join(context, 'lib')
    }
  },
  // devServer: {
  //   contentBase: path.resolve(pkg.config.buildDir),
  //   hot: true,
  //   noInfo: false,
  //   inline: true,
  //   stats: { colors: true }
  // }
};

module.exports = config;
<commit_msg>webpack: remove resolve.aliases<commit_after>var path = require('path');
var util = require('util');
// var autoprefixer = require('autoprefixer');
var pkg = require('../package.json');

var loaders = require('./loaders');
var plugins = require('./plugins');

var DEBUG = process.env.NODE_ENV === 'development';
var TEST = process.env.NODE_ENV === 'test';

var jsBundle = path.join('js', '[name].js');

var entry = {
  app: ['./app.js']
};

// if (DEBUG) {
//   entry.app.push(
//     util.format(
//       'webpack-dev-server/client?http://%s:%d',
//       pkg.config.devHost,
//       pkg.config.devPort
//     )
//   );
//   entry.app.push('webpack/hot/dev-server');
// }

var context = path.join(__dirname, '../resources/assets');
var config = {
  context: context,
  cache: DEBUG,
  debug: DEBUG,
  target: 'web',
  devtool: DEBUG || TEST ? 'inline-source-map' : 'source-map',
  entry: entry,
  output: {
    path: path.resolve(pkg.config.buildDir),
    publicPath: '/',
    filename: jsBundle,
    pathinfo: false
  },
  module: {
    loaders: loaders
  },
  // postcss: [
  //   autoprefixer
  // ],
  plugins: plugins,
  resolve: {
    extensions: ['', '.js', '.json', '.jsx']
  },
  // devServer: {
  //   contentBase: path.resolve(pkg.config.buildDir),
  //   hot: true,
  //   noInfo: false,
  //   inline: true,
  //   stats: { colors: true }
  // }
};

module.exports = config;
<|endoftext|>


<commit_before>'use strict';

let express = require('express')
let app = express()

app.use('/api/v1', require('./api'))
// app.use('/', requireg('./webapp'))

app.get('/', function (req, res) {
  res.send('Hello World!')
})

app.listen(3000, function () {
  console.log('Example app listening on port 3000!')
})
<commit_msg>using port 3001<commit_after>'use strict';

let express = require('express')
let app = express()

app.use('/api/v1', require('./api'))
// app.use('/', requireg('./webapp'))

app.get('/', function (req, res) {
  res.send('Hello World!')
})

app.listen(3001, function () {
  console.log('Example app listening on port 3001!')
})
<|endoftext|>


<commit_before>var fs    = require('fs')
var path  = require('path')
var chalk = require('chalk');

var webRoot  = __dirname;
var uppyRoot = path.dirname(__dirname);

var configPath = webRoot + '/_config.yml'
var config     = fs.readFileSync(configPath, 'utf-8')
var version    = require(uppyRoot + '/package.json').version

// Inject current Uppy version and sizes in website's _config.yml
var sizes     = {};
var locations = {
  min: uppyRoot + '/dist/uppy.js',
  gz : uppyRoot + '/dist/uppy.js',
  dev: uppyRoot + '/dist/uppy.js'
}
// @todo: ^-- Refer to actual minified builds in dist:

for (var file in locations) {
  var filesize = fs.statSync(locations[file], 'utf-8').size
  sizes[file] = (filesize / 1024).toFixed(2)
}

fs.writeFileSync(
  configPath,
  config
    .replace(/uppy_version: .*/, 'uppy_version: ' + version)
    .replace(/uppy_(\w+)_size:.*/g, function (m, p1) {
      return 'uppy_' + p1 + '_size: "' + (sizes[p1] || 99999 ) + '"'
    })
)

// Copy latest uppy version into website so the CDN example can use it
fs.writeFileSync(
  webRoot + '/themes/uppy/source/js/uppy.js',
  fs.readFileSync(locations.dev, 'utf-8')
);

console.info(chalk.green('✓ injected: uppy build into site'));
<commit_msg>Better colors<commit_after>var fs    = require('fs')
var path  = require('path')
var chalk = require('chalk');

var webRoot  = __dirname;
var uppyRoot = path.dirname(__dirname);

var configPath = webRoot + '/_config.yml'
var config     = fs.readFileSync(configPath, 'utf-8')
var version    = require(uppyRoot + '/package.json').version

// Inject current Uppy version and sizes in website's _config.yml
var sizes     = {};
var locations = {
  min: uppyRoot + '/dist/uppy.js',
  gz : uppyRoot + '/dist/uppy.js',
  dev: uppyRoot + '/dist/uppy.js'
}
// @todo: ^-- Refer to actual minified builds in dist:

for (var file in locations) {
  var filesize = fs.statSync(locations[file], 'utf-8').size
  sizes[file] = (filesize / 1024).toFixed(2)
}

fs.writeFileSync(
  configPath,
  config
    .replace(/uppy_version: .*/, 'uppy_version: ' + version)
    .replace(/uppy_(\w+)_size:.*/g, function (m, p1) {
      return 'uppy_' + p1 + '_size: "' + (sizes[p1] || 99999 ) + '"'
    })
)

// Copy latest uppy version into website so the CDN example can use it
fs.writeFileSync(
  webRoot + '/themes/uppy/source/js/uppy.js',
  fs.readFileSync(locations.dev, 'utf-8')
);

console.info(chalk.green('✓ injected: '), chalk.dim('uppy build into site'));
<|endoftext|>