Skip to content

Commit

Permalink
fix: auto install plugin in browser
Browse files Browse the repository at this point in the history
  • Loading branch information
pimlie committed Apr 26, 2020
1 parent fb89fc5 commit 32fdb20
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions scripts/rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 9 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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,
Expand Down

0 comments on commit 32fdb20

Please sign in to comment.