Skip to content

Instantly share code, notes, and snippets.

@ManUtopiK
Created October 2, 2020 20:23
Show Gist options
  • Select an option

  • Save ManUtopiK/7ebb2298491698536a809343bd0c8b70 to your computer and use it in GitHub Desktop.

Select an option

Save ManUtopiK/7ebb2298491698536a809343bd0c8b70 to your computer and use it in GitHub Desktop.
# config.js
const config = {
...,
features: {
...
}.
...
}
function feature (name) {
return config.features[name]
}
function parse (value, fallback) {
if (typeof value === 'undefined') {
return fallback
}
switch (typeof fallback) {
case 'boolean' :
return !!JSON.parse(value)
case 'number' :
return JSON.parse(value)
default :
return value
}
}
export {
config
}
export default {
install (Vue) {
Vue.appConfig = config
Vue.feature = feature
Vue.prototype.$appConfig = config
Vue.prototype.$feature = feature
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment