-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
This reverts commit b8c807a.
- Loading branch information
Showing
2 changed files
with
55 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |