forked from vuestorefront/vsf-capybara
-
Notifications
You must be signed in to change notification settings - Fork 0
/
local.config.js
68 lines (64 loc) · 1.8 KB
/
local.config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
const merge = require('lodash/merge')
const semverSatisfies = require('semver/functions/satisfies')
/**
* This is the base configuration for Capybara theme that is common and valid
* for all supported Vue Storefront versions. Any new configuration options
* which will be used in all installations regardless of Vue Storefront
* version should be added here.
*/
const configBase = {
'theme': '@vue-storefront/theme-capybara',
'products': {
'thumbnails': {
'width': 324,
'height': 489
}
},
'cart': {
'thumbnails': {
'width': 210,
'height': 300
}
},
'entities': {
'category': {
'categoriesDynamicPrefetch': false
}
},
'quicklink': {
'enabled': false
}
}
/**
* This object contains key-value pairs of custom/specific configuration options
* per matching Vue storefront version. Each key is a semver range about Vue
* Storefront version which supports these new options. Each value is a separate
* object cloned from base config and optionally extended by new configuration
* options supported by that particular Vue Storefront version.
*/
const configVariants = {
'~1.11.0': merge({}, configBase),
'^1.12.0': merge({}, configBase, {
'server': {
'api': 'api-search-query'
},
'entities': {
'attribute': {
'loadByAttributeMetadata': true
}
},
'urlModule': {
'enableMapFallbackUrl': true
}
})
}
/**
* Find and return first configuration that satisfies semver range for current
* Vue Storefront version.
*/
module.exports = function (vsfVersion) {
const matchedConfigVersion = Object
.keys(configVariants)
.find(configVersion => semverSatisfies(vsfVersion, configVersion, { includePrerelease: true }))
return matchedConfigVersion ? configVariants[matchedConfigVersion] : null
};