Skip to content

Commit

Permalink
Revert "temp: [REV-2674] reproduce webpack error in stage (#606)" (#607)
Browse files Browse the repository at this point in the history
This reverts commit b8c807a.
  • Loading branch information
pshiu committed May 31, 2022
1 parent b8c807a commit fc55534
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 22 deletions.
19 changes: 17 additions & 2 deletions audit-ci.json
Original file line number Diff line number Diff line change
@@ -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
}
58 changes: 38 additions & 20 deletions webpack.prod.config.js
Original file line number Diff line number Diff line change
@@ -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;

0 comments on commit fc55534

Please sign in to comment.