Skip to content
This repository was archived by the owner on Nov 4, 2024. It is now read-only.

Commit fc55534

Browse files
authored
Revert "temp: [REV-2674] reproduce webpack error in stage (#606)" (#607)
This reverts commit b8c807a.
1 parent b8c807a commit fc55534

File tree

2 files changed

+55
-22
lines changed

2 files changed

+55
-22
lines changed

audit-ci.json

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,23 @@
11
{
22
"allowlist": [
3+
1004946,
4+
1004967,
5+
1005009,
6+
1005059,
7+
1005174,
8+
1006865,
9+
1007026,
10+
1064611,
11+
1064664,
12+
1064843,
13+
1064906,
14+
1067285,
15+
1067280,
16+
1067278,
17+
1067279,
318
1067696,
4-
1070206,
5-
1070256
19+
1069976,
20+
1069985
621
],
722
"moderate": true
823
}

webpack.prod.config.js

Lines changed: 38 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,53 @@
1+
const path = require('path');
2+
const { mergeWithCustomize, unique } = require('webpack-merge');
13
const { getBaseConfig } = require('@edx/frontend-build');
24
// NOTE: This version of html-webpack-plugin must be the same major version as the one in
35
// frontend-build to avoid potential issues.
6+
const HtmlWebpackPlugin = require('html-webpack-plugin');
47

58
/**
6-
* This plugin configuration edits the default in webpack-prod for the following reasons:
9+
* This plugin configuration overrides the default in webpack-prod for the following reasons:
710
*
811
* We need to have a custom html-webpack-plugin configuration to allow us to preconnect to
912
* various domains. See the public/index.html file for the companion usage of this configuration.
1013
*/
1114

12-
const config = getBaseConfig('webpack-prod');
15+
const config = mergeWithCustomize({
16+
customizeArray: unique(
17+
'plugins',
18+
['HtmlWebpackPlugin'],
19+
plugin => plugin.constructor && plugin.constructor.name,
20+
),
21+
})(
22+
getBaseConfig('webpack-prod'),
23+
{
24+
plugins: [
25+
// Generates an HTML file in the output directory.
26+
new HtmlWebpackPlugin({
27+
inject: false, // Manually inject head and body tags in the template itself.
28+
template: path.resolve(__dirname, 'public/index.html'),
29+
FAVICON_URL: process.env.FAVICON_URL || null,
30+
OPTIMIZELY_PROJECT_ID: process.env.OPTIMIZELY_PROJECT_ID || null,
31+
preconnect: (() => {
32+
const preconnectDomains = [
33+
'https://api.segment.io',
34+
'https://cdn.segment.com',
35+
'https://www.google-analytics.com',
36+
];
1337

14-
/* eslint-disable no-param-reassign */
15-
config.plugins.forEach((plugin) => {
16-
if (plugin.constructor.name === 'HtmlWebpackPlugin') {
17-
const preconnectDomains = [
18-
'https://api.segment.io',
19-
'https://cdn.segment.com',
20-
'https://www.google-analytics.com',
21-
];
38+
if (process.env.LMS_BASE_URL) {
39+
preconnectDomains.push(process.env.LMS_BASE_URL);
40+
}
2241

23-
if (process.env.LMS_BASE_URL) {
24-
preconnectDomains.push(process.env.LMS_BASE_URL);
25-
}
42+
if (process.env.OPTIMIZELY_PROJECT_ID) {
43+
preconnectDomains.push('https://logx.optimizely.com');
44+
}
2645

27-
if (process.env.OPTIMIZELY_PROJECT_ID) {
28-
preconnectDomains.push('https://logx.optimizely.com');
29-
}
30-
31-
plugin.userOptions.preconnect = preconnectDomains;
32-
}
33-
});
46+
return preconnectDomains;
47+
})(),
48+
}),
49+
],
50+
},
51+
);
3452

3553
module.exports = config;

0 commit comments

Comments
 (0)