Skip to content

Instantly share code, notes, and snippets.

@Sixl-Daniel
Last active October 4, 2020 09:10
Show Gist options
  • Save Sixl-Daniel/c191dbb42b4f01a60e94547ee57a1e66 to your computer and use it in GitHub Desktop.
Save Sixl-Daniel/c191dbb42b4f01a60e94547ee57a1e66 to your computer and use it in GitHub Desktop.

Revisions

  1. Sixl-Daniel renamed this gist Oct 4, 2020. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  2. Sixl-Daniel created this gist Oct 4, 2020.
    40 changes: 40 additions & 0 deletions config.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,40 @@
    # 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
    }
    }
    5 changes: 5 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,5 @@
    # main.js

    import Vue from 'vue`
    import configPlugin from '@/config'
    Vue.use(configPlugin)