From 32fdb2001a5cb0b595c9db67d1b5a75da7f85902 Mon Sep 17 00:00:00 2001 From: pimlie Date: Sun, 26 Apr 2020 13:28:02 +0200 Subject: [PATCH] fix: auto install plugin in browser --- scripts/rollup.config.js | 1 + src/index.js | 9 +++++++++ 2 files changed, 10 insertions(+) diff --git a/scripts/rollup.config.js b/scripts/rollup.config.js index f0d9a72b..181fae05 100644 --- a/scripts/rollup.config.js +++ b/scripts/rollup.config.js @@ -85,6 +85,7 @@ function rollupConfig({ // replaceConfig needs to have some values 'const polyfill = process.env.NODE_ENV === \'test\'': 'const polyfill = true', 'process.env.VERSION': `"${version}"`, + 'process.client' : isBrowserBuild ? 'true' : 'false', 'process.server' : isBrowserBuild ? 'false' : 'true', /* remove unused stuff from deepmerge */ // remove react stuff from is-mergeable-object diff --git a/src/index.js b/src/index.js index 280b12d5..298c66cf 100644 --- a/src/index.js +++ b/src/index.js @@ -5,6 +5,7 @@ import { setOptions } from './shared/options' import $meta from './shared/$meta' import generate from './server/generate' import { hasMetaInfo } from './shared/meta-helpers' +import { isUndefined } from './utils/is-type' /** * Plugin install function. @@ -25,6 +26,14 @@ function install (Vue, options) { Vue.mixin(createMixin(Vue, options)) } +if (process.client) { + // automatic install + if (!isUndefined(window) && !isUndefined(window.Vue)) { + /* istanbul ignore next */ + install(window.Vue) + } +} + export default { version, install,