Skip to content

Commit

Permalink
magento#1617 - Fetch store name from the GraphQL server at compile time
Browse files Browse the repository at this point in the history
  • Loading branch information
Vasilii Burlacu committed Feb 19, 2021
1 parent 3902295 commit 69eed60
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@ query {
code
locale
secure_base_media_url
store_name
}
}
14 changes: 13 additions & 1 deletion packages/venia-concept/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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),
Expand Down

0 comments on commit 69eed60

Please sign in to comment.