Skip to content

Commit

Permalink
refactor: support process.env.PARAGON_THEME_URLS
Browse files Browse the repository at this point in the history
  • Loading branch information
dcoa committed Aug 9, 2024
1 parent 182100f commit 516c1bf
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions lib/plugins/paragon-webpack-plugin/ParagonWebpackPlugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,23 +41,24 @@ class ParagonWebpackPlugin {
}

/**
* Resolves the MFE configuration for ``PARAGON_THEME_URLS`` in env.config.js
* Resolves the MFE configuration for ``PARAGON_THEME_URLS`` in the following priority order:
*
* 1. ``envConfig.PARAGON_THEME_URLS`` (JS based)
* 3. ``process.env.PARAGON_THEME_URLS`` (JSON based)
*
* @returns {Object} Metadata about the Paragon and brand theme URLs from configuration.
*/
async resolveParagonThemeUrlsFromConfig() {
let envConfig;
if (fs.existsSync(envConfigFile)) {
try {
try {
if (fs.existsSync(envConfigFile)) {
envConfig = require(envConfigFile);
} catch (error) {
console.info('Paragon Plugin cannot load env.config file, if you want to preload the theme url be sure your file is a CommonJS module');
}
const paragonThemeUrls = envConfig?.PARAGON_THEME_URLS ?? JSON.parse(process.env.PARAGON_THEME_URLS);
this.paragonThemeUrlsConfig = paragonThemeUrls;
} catch (error) {
console.info('Paragon Plugin cannot load PARAGON_THEME_URLS, skipping.');
}

const paragonThemeUrls = envConfig?.PARAGON_THEME_URLS ?? {};

this.paragonThemeUrlsConfig = paragonThemeUrls;
}

/**
Expand Down

0 comments on commit 516c1bf

Please sign in to comment.