diff --git a/audit-ci.json b/audit-ci.json index 7855cc1f2..f83d5e819 100644 --- a/audit-ci.json +++ b/audit-ci.json @@ -1,8 +1,23 @@ { "allowlist": [ + 1004946, + 1004967, + 1005009, + 1005059, + 1005174, + 1006865, + 1007026, + 1064611, + 1064664, + 1064843, + 1064906, + 1067285, + 1067280, + 1067278, + 1067279, 1067696, - 1070206, - 1070256 + 1069976, + 1069985 ], "moderate": true } diff --git a/webpack.prod.config.js b/webpack.prod.config.js index b79fe179a..efc5f90c6 100644 --- a/webpack.prod.config.js +++ b/webpack.prod.config.js @@ -1,35 +1,53 @@ +const path = require('path'); +const { mergeWithCustomize, unique } = require('webpack-merge'); const { getBaseConfig } = require('@edx/frontend-build'); // NOTE: This version of html-webpack-plugin must be the same major version as the one in // frontend-build to avoid potential issues. +const HtmlWebpackPlugin = require('html-webpack-plugin'); /** - * This plugin configuration edits the default in webpack-prod for the following reasons: + * This plugin configuration overrides the default in webpack-prod for the following reasons: * * We need to have a custom html-webpack-plugin configuration to allow us to preconnect to * various domains. See the public/index.html file for the companion usage of this configuration. */ -const config = getBaseConfig('webpack-prod'); +const config = mergeWithCustomize({ + customizeArray: unique( + 'plugins', + ['HtmlWebpackPlugin'], + plugin => plugin.constructor && plugin.constructor.name, + ), +})( + getBaseConfig('webpack-prod'), + { + plugins: [ + // Generates an HTML file in the output directory. + new HtmlWebpackPlugin({ + inject: false, // Manually inject head and body tags in the template itself. + template: path.resolve(__dirname, 'public/index.html'), + FAVICON_URL: process.env.FAVICON_URL || null, + OPTIMIZELY_PROJECT_ID: process.env.OPTIMIZELY_PROJECT_ID || null, + preconnect: (() => { + const preconnectDomains = [ + 'https://api.segment.io', + 'https://cdn.segment.com', + 'https://www.google-analytics.com', + ]; -/* eslint-disable no-param-reassign */ -config.plugins.forEach((plugin) => { - if (plugin.constructor.name === 'HtmlWebpackPlugin') { - const preconnectDomains = [ - 'https://api.segment.io', - 'https://cdn.segment.com', - 'https://www.google-analytics.com', - ]; + if (process.env.LMS_BASE_URL) { + preconnectDomains.push(process.env.LMS_BASE_URL); + } - if (process.env.LMS_BASE_URL) { - preconnectDomains.push(process.env.LMS_BASE_URL); - } + if (process.env.OPTIMIZELY_PROJECT_ID) { + preconnectDomains.push('https://logx.optimizely.com'); + } - if (process.env.OPTIMIZELY_PROJECT_ID) { - preconnectDomains.push('https://logx.optimizely.com'); - } - - plugin.userOptions.preconnect = preconnectDomains; - } -}); + return preconnectDomains; + })(), + }), + ], + }, +); module.exports = config;