diff --git a/src/scripts/index.js b/src/scripts/index.js index f37adc81..8f531b8c 100644 --- a/src/scripts/index.js +++ b/src/scripts/index.js @@ -1,3 +1,5 @@ +import featherIcons from 'feather-vue' + // plugins import Components from './components' @@ -14,8 +16,22 @@ const mixins = { validatable, resettable } export const Clair = { mixins, install (Vue) { + const VuePrototype = Vue.prototype + const defineReadOnly = function (key, val) { + Object.defineProperty(VuePrototype, key, { + get () { + return val + }, + configurable: process.env.NODE_ENV !== 'production', + enumerable: false + }) + } + + // set a noop utility + defineReadOnly('noop', _ => _) + // inject $clair to Vue prototype - if (!('$clair' in Vue.prototype)) { + if (!('$clair' in VuePrototype)) { const $clair = new Vue({ data: { responsive: null, @@ -23,18 +39,15 @@ export const Clair = { } }) $clair.mixins = mixins - - Object.defineProperty(Vue.prototype, '$clair', { - get () { - return $clair - } - }) + defineReadOnly('$clair', $clair) } - Vue.prototype.noop = () => {} + // expose featherIcons for convenience + defineReadOnly('$featherIcons', featherIcons) // register components Vue.use(Components) + // install plugins Vue.use(Modal) Vue.use(Responsive)