Skip to content

Commit a8fdea4

Browse files
authored
Merge pull request #5562 from vuestorefront/purge-loader-dynamic-conf-fix
fix: purgeLoader with dynamicConfigReload
2 parents f51ad9e + f64d80d commit a8fdea4

File tree

6 files changed

+28
-17
lines changed

6 files changed

+28
-17
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
3838
- Got rid of memory leak related to dynamic config - tomasz-duda (#4768)
3939
- servercart-after-diff event payload - Fifciu (#5365)
4040
- Fix Original Price Calculation typo - @akucharczyk / @lukaszjedrasik (#5472)
41+
- Purge loader works properly with dynamic config reload - @Fifciu
4142
### Changed / Improved
4243

4344
- Moved hardcoded fields from omitSelectedVariantFields.ts to config (#4679)

core/build/purge-config.js

Lines changed: 0 additions & 16 deletions
This file was deleted.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import omit from 'lodash/omit';
2+
3+
export default config => {
4+
const purgeConfig = (config.purgeConfig || []).slice();
5+
6+
config = omit(config, purgeConfig);
7+
delete config['purgeConfig'];
8+
9+
return config;
10+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import purgeConfig from './purgeConfig';
2+
3+
/**
4+
* clear config properties that shouldn't be visible on frontend
5+
*/
6+
export default function loader (source) {
7+
let config = JSON.parse(source);
8+
config = purgeConfig(config);
9+
10+
return JSON.stringify(config);
11+
}

core/build/webpack.base.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ export default {
196196
},
197197
{
198198
test: /core\/build\/config\.json$/,
199-
loader: path.resolve('core/build/purge-config.js')
199+
loader: path.resolve('core/build/purge-config/purgeConfigLoader.ts')
200200
}
201201
]
202202
}

core/server-entry.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import config from 'config'
1010
import { Logger } from '@vue-storefront/core/lib/logger'
1111
import { RouterManager } from './lib/router-manager';
1212
import queryString from 'query-string'
13+
import purgeConfig from './build/purge-config/purgeConfig';
1314

1415
function _commonErrorHandler (err, reject) {
1516
if (err.message.indexOf('query returned empty result') > 0) {
@@ -43,6 +44,10 @@ function _ssrHydrateSubcomponents (components, store, router, resolve, reject, a
4344
if (excludeFromConfig && excludeFromConfig.length > 0) {
4445
context.state.config = omit(context.state.config, excludeFromConfig)
4546
}
47+
context.state.config = purgeConfig({
48+
...context.state.config,
49+
purgeConfig: buildTimeConfig.purgeConfig
50+
})
4651
}
4752
resolve(app)
4853
}).catch(err => {

0 commit comments

Comments
 (0)