'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); var __assign = function() { __assign = Object.assign || function __assign(t) { for (var s, i = 1, n = arguments.length; i < n; i++) { s = arguments[i]; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; } return t; }; return __assign.apply(this, arguments); }; function __spreadArray(to, from, pack) { if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) { if (ar || !(i in from)) { if (!ar) ar = Array.prototype.slice.call(from, 0, i); ar[i] = from[i]; } } return to.concat(ar || from); } function bodySnippet(id) { return '
'; } var homePage = { staticPage: true, buildExclude: false, title: 'Home', filename: 'index.html', html: { head: {}, body: { scripts: [], snippet: bodySnippet('page-home'), } }, window: {}, render: 'import { renderPage } from \'./js/helpers\'; import { HomePage } from \'./js/pages/HomePage\'; renderPage( \'page-home\', HomePage );', }; var errorPage = { staticPage: true, buildExclude: false, title: 'Error', filename: 'error.html', html: { head: {}, body: { scripts: [], snippet: bodySnippet('page-error'), } }, window: {}, render: 'import { renderPage } from \'./js/helpers\'; import { ErrorPage } from \'./js/pages/ErrorPage\'; renderPage( \'page-error\', ErrorPage );', }; var pages = { home: homePage, error: errorPage, }; var htmlHead = { meta: [ { charset: 'utf-8' }, { content: 'ie=edge', 'http-equiv': 'x-ua-compatible' }, { name: 'viewport', content: 'width=device-width, initial-scale=1' }, ], links: [], scripts: [], }; var htmlBody = { scripts: [], snippet: '', }; var html = { head: htmlHead, body: htmlBody, }; var config$3 = { src: '', build: '', pages: pages, html: html, window: {}, postcssConfigFile: '', }; /*const chunksCacheGroups_0 = { commons: { test: /[\\/]src[\\/]/, name: "_commons", chunks: "all", enforce: true, reuseExistingChunk: true, }, };*/ /*const chunksCacheGroups_1 = { commons: { test: /[\\/]src[\\/]/, name: "_commons", // priority: -10, chunks: "all", enforce: true, reuseExistingChunk: true, }, vendors: { test: /[\\/]node_modules[\\/]/, // test: /[\\/]node_modules[\\/](react|react-dom)[\\/]/, // test: /[\\/]node_modules[\\/](!MediaCmsPlayer)[\\/]/, name: "_vendors", // priority: -20, chunks: "all", enforce: true, // reuseExistingChunk: true, }, };*/ /*const chunksCacheGroups_2 = { commons: { minChunks: 2, // maxInitialRequests: 8, // @note: Tested values from 0 to 10, and changes applied with values 0, 4, 5, 6, 7, 8. // minSize: 0, name: "_commons", chunks: "all", enforce: true, reuseExistingChunk: true, }, };*/ /*const chunksCacheGroups_3 = { vendors: { test: /[\\/]node_modules[\\/]/, name: "_commons", priority: 1, chunks: "initial", }, };*/ var config$2 = { mode: 'production', devtool: 'source-map', optimization: { runtimeChunk: false, /*splitChunks: { // minSize: 1000000, chunks: 'all', automaticNameDelimiter: '-', },*/ /*splitChunks: { // minSize: 1000000, chunks: 'all', automaticNameDelimiter: '-', cacheGroups: chunksCacheGroups_0, },*/ /*splitChunks: { chunks: 'all', automaticNameDelimiter: '-', cacheGroups: chunksCacheGroups_1, },*/ /*splitChunks: { chunks: 'all', automaticNameDelimiter: '-', cacheGroups: chunksCacheGroups_2, },*/ /*splitChunks: { chunks: 'all', automaticNameDelimiter: '-', cacheGroups: chunksCacheGroups_3, },*/ splitChunks: { chunks: 'all', automaticNameDelimiter: '-', cacheGroups: { vendors: { test: /[\\/]node_modules[\\/]/, name: "_commons", priority: 1, chunks: "initial", }, }, }, } }; /*const chunksCacheGroups_0 = { commons: { test: /[\\/]src[\\/]/, name: "_commons", chunks: "all", enforce: true, reuseExistingChunk: true, }, }; const chunksCacheGroups_1 = { commons: { test: /[\\/]src[\\/]/, name: "_commons", // priority: -10, chunks: "all", enforce: true, reuseExistingChunk: true, }, vendors: { test: /[\\/]node_modules[\\/]/, // test: /[\\/]node_modules[\\/](react|react-dom)[\\/]/, // test: /[\\/]node_modules[\\/](!MediaCmsPlayer)[\\/]/, name: "_vendors", // priority: -20, chunks: "all", enforce: true, // reuseExistingChunk: true, }, }; const chunksCacheGroups_2 = { commons: { minChunks: 2, // maxInitialRequests: 8, // @note: Tested values from 0 to 10, and changes applied with values 0, 4, 5, 6, 7, 8. // minSize: 0, name: "_commons", chunks: "all", enforce: true, reuseExistingChunk: true, }, }; const chunksCacheGroups_3 = { vendors: { test: /[\\/]node_modules[\\/]/, name: "_commons", priority: 1, chunks: "initial", }, };*/ var config$1 = { mode: 'production', optimization: { minimize: true, runtimeChunk: false, splitChunks: { chunks: 'all', automaticNameDelimiter: '-', cacheGroups: { vendors: { test: /[\\/]node_modules[\\/]/, name: "_commons", priority: 1, chunks: "initial", }, }, }, } }; /** * @see {link: https://github.com/seeyoulater/html-beautify-webpack-plugin/blob/master/index.js} */ var prettify = require('html-prettify'); var HtmlWebpackPlugin$1 = require('html-webpack-plugin'); require('webpack/lib/WebpackError.js'); function htmlPluginDataFunction(pluginData, options, callback) { pluginData.html = prettify(options.replace.reduce(function (res, item) { return res.replace(item instanceof RegExp ? new RegExp(item, 'gi') : item, ''); }, pluginData.html) /*, options.config*/); callback(null, pluginData); } var MyHtmlBeautifyWebpackPlugin = /** @class */ (function () { function MyHtmlBeautifyWebpackPlugin() { } MyHtmlBeautifyWebpackPlugin.prototype.apply = function (compiler) { var options = { config: { indent_size: 4, indent_with_tabs: false, html: { end_with_newline: true, indent_inner_html: true, preserve_newlines: true, max_preserve_newlines: 0, } }, replace: [] }; function tapAsyncCallback(pluginData, callback) { return htmlPluginDataFunction(pluginData, options, callback); } function tapHookCallback(compilation) { return HtmlWebpackPlugin$1.getHooks(compilation).beforeEmit.tapAsync('MyHtmlBeautifyWebpackPlugin', tapAsyncCallback); } compiler.hooks.compilation.tap('MyHtmlBeautifyWebpackPlugin', tapHookCallback); }; return MyHtmlBeautifyWebpackPlugin; }()); var fs = require('fs'); var path$1 = require('path'); var ejs = require('ejs'); var templatePath = path$1.join(__dirname, '../templates'); var sitemapTemplatePath = path$1.join(templatePath, 'sitemap.ejs'); var sitemapTemplate = ejs.compile(fs.readFileSync(sitemapTemplatePath, 'utf8'), { root: [templatePath], filename: sitemapTemplatePath, outputFunctionName: 'echo' }); function pagesConfig(pagesKeys) { var pages = {}; if (-1 === pagesKeys.indexOf('sitemap')) { pages.sitemap = { staticPage: true, buildExclude: true, title: 'Sitemap', filename: 'sitemap.html', html: { head: {}, body: { scripts: [], snippet: sitemapTemplate({ pages: __spreadArray(__spreadArray([], pagesKeys), Object.keys(pages)) }), }, }, window: {}, render: '' }; } return pages; } var merge = require('lodash.merge'); function validateBoolean(value, defaultValue) { if (defaultValue === void 0) { defaultValue = false; } if (true === value || false === value) { return value; } if (0 === value || 1 === value) { return !!value; } return defaultValue; } function validateString(value, defaultValue) { if (defaultValue === void 0) { defaultValue = ''; } return value ? value : defaultValue; } function getArrayType(sourcesArr, pageArr) { if (pageArr === void 0) { pageArr = []; } if ((!sourcesArr || !sourcesArr.length) && (!pageArr || !pageArr.length)) { return []; } if (sourcesArr && sourcesArr.length && pageArr && pageArr.length) { return sourcesArr.concat(pageArr); } if (sourcesArr && sourcesArr.length) { return sourcesArr; } return pageArr; } function formatPagesConfig(sources, pages) { var ret = {}; for (var pk in pages) { ret[pk] = { staticPage: validateBoolean(pages[pk].staticPage, false), buildExclude: validateBoolean(pages[pk].buildExclude, false), title: validateString(pages[pk].title, sources.title), filename: validateString(pages[pk].filename, sources.filename), html: { head: { meta: getArrayType(sources.html.head.meta, pages[pk].html.head.meta), links: getArrayType(sources.html.head.links, pages[pk].html.head.links), scripts: getArrayType(sources.html.head.scripts, pages[pk].html.head.scripts), }, body: { scripts: getArrayType(sources.html.body.scripts, pages[pk].html.body.scripts), snippet: validateString(pages[pk].html.body.snippet, sources.html.body.snippet), }, }, window: merge({}, sources.window, pages[pk].window), render: validateString(sources.render, pages[pk].render), }; } return ret; } var path = require('path'); var NodePolyfillPlugin = require("node-polyfill-webpack-plugin"); // Webpack plugins. var DefinePlugin = require('webpack').DefinePlugin; var LimitChunkCountPlugin = require('webpack').optimize.LimitChunkCountPlugin; var HtmlWebpackPlugin = require('html-webpack-plugin'); var VirtualModulesPlugin = require('webpack-virtual-modules'); var MiniCssExtractPlugin = require('mini-css-extract-plugin'); var ProgressBarPlugin = require('progress-bar-webpack-plugin'); var CssMinimizerPlugin = require('css-minimizer-webpack-plugin'); var CopyPlugin = require("copy-webpack-plugin"); var dotenv = require('dotenv').config({ path: path.resolve(__dirname + '../../../../.env') }); function webpackEntry(env, srcDir, pages) { var ret = {}; for (var p in pages) { if ('development' === env || !pages[p].buildExclude) { ret[p] = path.resolve(srcDir + '/' + p + '.js'); } } return ret; } function webpackOutput(env, destinationDir, buildDir, chunkhash, hash) { var ret = { path: destinationDir, filename: '', }; var prefix = 'development' === env ? '' : buildDir; var tmp; if (undefined !== chunkhash) { tmp = chunkhash.trim(); if ('' === tmp) { throw Error('Invalid chunkhash argument value: ' + chunkhash); } ret.filename = (prefix || '') + '[name]-[chunkhash].js'; } else if (undefined !== hash) { tmp = hash.trim(); if ('' === tmp) { throw Error('Invalid hash argument value: ' + hash); } ret.filename = (prefix || '') + '[name]-[hash].js'; } else { ret.filename = (prefix || '') + '[name].js'; } return ret; } function webpackAlias() { return { // modernizr$: path.resolve(__dirname, "../../.modernizrrc"), // TODO: Enable this? }; } function webpackRules(env, srcDir, postcssConfigFile) { return [{ test: /\.(jsx|js)?$/, use: 'babel-loader' }, { test: /\.(tsx|ts)?$/, use: 'ts-loader', // exclude: /node_modules/, // options: { // compilerOptions: { // "sourceMap": !isProduction, // }, // }, }, { test: /\.ejs$/, use: { loader: 'ejs-compiled-loader', options: { // beautify: true, htmlmin: true, // htmlminOptions: { // removeComments: true, // collapseWhitespace: true, // preserveLineBreaks: true // } } } }, { test: /\.(sa|sc|c)ss$/, use: [ { loader: MiniCssExtractPlugin.loader }, // { loader: 'development' === env ? MiniCssExtractPlugin.loader : 'style-loader' }, // Use inline