diff --git a/landing/webpack.config.cjs b/landing/webpack.config.cjs --- a/landing/webpack.config.cjs +++ b/landing/webpack.config.cjs @@ -65,14 +65,19 @@ }, }; -module.exports = function (env) { - const browserConfig = env.prod +module.exports = async function (env) { + const browserConfigPromise = env.prod ? createProdBrowserConfig(baseProdBrowserConfig, babelConfig) : createDevBrowserConfig(baseDevBrowserConfig, babelConfig); - const nodeConfig = createNodeServerRenderingConfig( + const nodeConfigPromise = createNodeServerRenderingConfig( baseNodeServerRenderingConfig, babelConfig, ); + const [browserConfig, nodeConfig] = await Promise.all([ + browserConfigPromise, + nodeConfigPromise, + ]); + const nodeServerRenderingConfig = { ...nodeConfig, mode: env.prod ? 'production' : 'development', diff --git a/lib/webpack/shared.cjs b/lib/webpack/shared.cjs --- a/lib/webpack/shared.cjs +++ b/lib/webpack/shared.cjs @@ -5,6 +5,14 @@ const TerserPlugin = require('terser-webpack-plugin'); const webpack = require('webpack'); +async function getConfig(configName) { + const { getCommConfig } = await import( + // eslint-disable-next-line monorepo/no-relative-import + '../../keyserver/dist/lib/utils/comm-config.js' + ); + return await getCommConfig(configName); +} + const sharedPlugins = [ new webpack.optimize.LimitChunkCountPlugin({ maxChunks: 1, @@ -89,12 +97,20 @@ }; } -const alchemyKey = process.env.COMM_ALCHEMY_KEY; -const walletConnectKey = process.env.COMM_WALLETCONNECT_KEY; +async function getConfigs() { + const [alchemySecret, walletConnectSecret] = await Promise.all([ + getConfig({ folder: 'secrets', name: 'alchemy' }), + getConfig({ folder: 'secrets', name: 'walletconnect' }), + ]); + const alchemyKey = alchemySecret?.key; + const walletConnectKey = walletConnectSecret?.key; + return { alchemyKey, walletConnectKey }; +} -function createProdBrowserConfig(baseConfig, babelConfig) { +async function createProdBrowserConfig(baseConfig, babelConfig) { const browserConfig = createBaseBrowserConfig(baseConfig); const babelRule = getBrowserBabelRule(babelConfig); + const { alchemyKey, walletConnectKey } = await getConfigs(); return { ...browserConfig, mode: 'production', @@ -159,9 +175,10 @@ }; } -function createDevBrowserConfig(baseConfig, babelConfig) { +async function createDevBrowserConfig(baseConfig, babelConfig) { const browserConfig = createBaseBrowserConfig(baseConfig); const babelRule = getBrowserBabelRule(babelConfig); + const { alchemyKey, walletConnectKey } = await getConfigs(); return { ...browserConfig, mode: 'development', @@ -216,7 +233,8 @@ }; } -function createNodeServerRenderingConfig(baseConfig, babelConfig) { +async function createNodeServerRenderingConfig(baseConfig, babelConfig) { + const { alchemyKey, walletConnectKey } = await getConfigs(); return { ...baseConfig, name: 'server', diff --git a/web/webpack.config.cjs b/web/webpack.config.cjs --- a/web/webpack.config.cjs +++ b/web/webpack.config.cjs @@ -158,14 +158,19 @@ }), ]; -module.exports = function (env) { - const browserConfig = env.prod +module.exports = async function (env) { + const browserConfigPromise = env.prod ? createProdBrowserConfig(baseProdBrowserConfig, babelConfig) : createDevBrowserConfig(baseDevBrowserConfig, babelConfig); - const nodeConfig = createNodeServerRenderingConfig( + const nodeConfigPromise = createNodeServerRenderingConfig( baseNodeServerRenderingConfig, babelConfig, ); + const [browserConfig, nodeConfig] = await Promise.all([ + browserConfigPromise, + nodeConfigPromise, + ]); + const nodeServerRenderingConfig = { ...nodeConfig, mode: env.prod ? 'production' : 'development',