const path = require('path'); const NodePolyfillPlugin = require("node-polyfill-webpack-plugin"); // Webpack plugins. const { DefinePlugin } = require('webpack'); const { LimitChunkCountPlugin } = require('webpack').optimize; const HtmlWebpackPlugin = require('html-webpack-plugin'); const VirtualModulesPlugin = require('webpack-virtual-modules'); const MiniCssExtractPlugin = require('mini-css-extract-plugin'); const ProgressBarPlugin = require('progress-bar-webpack-plugin'); const CssMinimizerPlugin = require('css-minimizer-webpack-plugin'); const CopyPlugin = require("copy-webpack-plugin"); var dotenv = require('dotenv').config({ path: path.resolve(__dirname + '../../../../.env') }); import MyHtmlBeautifyWebpackPlugin from '../webpack-plugins/MyHtmlBeautifyWebpackPlugin'; import { ConfigType, ConfigPages } from '../config'; import defaultPages from './pagesConfig'; import formatPagesConfig from './formatPagesConfig'; function webpackEntry(env: string, srcDir: string, pages: ConfigPages) { const ret: { [key: string]: string } = {}; for (const p in pages) { if ('development' === env || !pages[p].buildExclude) { ret[p] = path.resolve(srcDir + '/' + p + '.js'); } } return ret; } function webpackOutput(env: string, destinationDir: string, buildDir?: string, chunkhash?: string, hash?: string) { const ret = { path: destinationDir, filename: '', }; const prefix = 'development' === env ? '' : buildDir; let 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: string, srcDir: string, postcssConfigFile: string): any[] { 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