Skip to content

Commit f055390

Browse files
authored
PWA-3261 : Multi store setup fix (#4456)
* Added code for dynamic dist and index.html generation * yarn prettier commit
1 parent 8fce578 commit f055390

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

packages/venia-concept/webpack.config.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ const HTMLWebpackPlugin = require('html-webpack-plugin');
33
const webpack = require('webpack');
44
const fs = require('fs');
55
const { promisify } = require('util');
6+
const path = require('path');
67

78
const {
89
getMediaURL,
@@ -72,6 +73,20 @@ module.exports = async env => {
7273
({ store_code }) => store_code === process.env.STORE_VIEW_CODE
7374
);
7475

76+
/**
77+
* Here we check the STORE_VIEW_CODE for multistore setup and generate
78+
* the index.html content to have the store code in script url
79+
* and placed the assets in storeview specific folder inside dist
80+
*/
81+
if (process.env.USE_STORE_CODE_IN_URL && process.env.STORE_VIEW_CODE) {
82+
const storeViewCode = process.env.STORE_VIEW_CODE;
83+
config.output = {
84+
...config.output,
85+
publicPath: `/${storeViewCode}/`,
86+
path: path.resolve(__dirname, 'dist', storeViewCode)
87+
};
88+
}
89+
7590
global.MAGENTO_MEDIA_BACKEND_URL = mediaUrl;
7691
global.LOCALE = storeConfigData.locale.replace('_', '-');
7792
global.AVAILABLE_STORE_VIEWS = availableStores;

0 commit comments

Comments
 (0)