diff --git a/packages/pwa-buildpack/lib/queries/getStoreConfigData.graphql b/packages/pwa-buildpack/lib/queries/getStoreConfigData.graphql index 67b9d5a0b9..3fa0ba80c0 100644 --- a/packages/pwa-buildpack/lib/queries/getStoreConfigData.graphql +++ b/packages/pwa-buildpack/lib/queries/getStoreConfigData.graphql @@ -5,5 +5,6 @@ query { code locale secure_base_media_url + store_name } } diff --git a/packages/venia-concept/webpack.config.js b/packages/venia-concept/webpack.config.js index 073e3a9dd9..b8c63d7fd6 100644 --- a/packages/venia-concept/webpack.config.js +++ b/packages/venia-concept/webpack.config.js @@ -45,8 +45,18 @@ module.exports = async env => { const storeConfigData = await getStoreConfigData(); const { availableStores } = await getAvailableStoresConfigData(); + /** + * Loop the available stores when there is provided STORE_VIEW_CODE + * in the .env file, because should set the store name from the + * given store code instead of the default one. + */ + const availableStore = process.env.STORE_VIEW_CODE + ? availableStores.find(store => store.code === process.env.STORE_VIEW_CODE) + : undefined; + global.MAGENTO_MEDIA_BACKEND_URL = mediaUrl; global.LOCALE = storeConfigData.locale.replace('_', '-'); + global.STORE_NAME = storeConfigData.store_name; global.AVAILABLE_STORE_VIEWS = availableStores; const possibleTypes = await getPossibleTypes(); @@ -63,7 +73,9 @@ module.exports = async env => { * the globals object in jest.config.js. */ POSSIBLE_TYPES: JSON.stringify(possibleTypes), - STORE_NAME: JSON.stringify('Venia'), + STORE_NAME: process.env.STORE_VIEW_CODE && availableStore + ? JSON.stringify(availableStore.store_name) + : JSON.stringify(global.STORE_NAME), STORE_VIEW_CODE: process.env.STORE_VIEW_CODE ? JSON.stringify(process.env.STORE_VIEW_CODE) : JSON.stringify(storeConfigData.code),