A configuration manager for Vue
npm install vue-config-manager
This example will add a debug
variable to the config manager
import VueConfigManager from 'vue-config-manager'
Vue.use(VueConfigManager, {
defaults: {
debug: true,
api: {
base: 'http://graph.facebook.com/'
}
}
})
You can retrieve this variable inside a Vue component
Vue.component('example', {
mounted () {
const debug = this.$config('debug')
const base = this.$config('api.base')
}
})
When you need different configuration for a specific environment
Vue.use(VueConfigManager, {
defaults: {
debug: true
},
environment: {
debug: false
}
})
However, if you're not running in a server environment you can also get desired configuration based on the hostname of your app.
Vue.use(VueConfigManager, {
defaults: {
debug: true
},
hosts: {
'localhost': {
debug: false
}
}
})
# install deps
npm install
# build dist files
npm run build
# serve examples at localhost:8080
npm run dev
# run all tests
npm test