Skip to content

Commit 32fdb20

Browse files
committed
fix: auto install plugin in browser
1 parent fb89fc5 commit 32fdb20

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

scripts/rollup.config.js

+1
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ function rollupConfig({
8585
// replaceConfig needs to have some values
8686
'const polyfill = process.env.NODE_ENV === \'test\'': 'const polyfill = true',
8787
'process.env.VERSION': `"${version}"`,
88+
'process.client' : isBrowserBuild ? 'true' : 'false',
8889
'process.server' : isBrowserBuild ? 'false' : 'true',
8990
/* remove unused stuff from deepmerge */
9091
// remove react stuff from is-mergeable-object

src/index.js

+9
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { setOptions } from './shared/options'
55
import $meta from './shared/$meta'
66
import generate from './server/generate'
77
import { hasMetaInfo } from './shared/meta-helpers'
8+
import { isUndefined } from './utils/is-type'
89

910
/**
1011
* Plugin install function.
@@ -25,6 +26,14 @@ function install (Vue, options) {
2526
Vue.mixin(createMixin(Vue, options))
2627
}
2728

29+
if (process.client) {
30+
// automatic install
31+
if (!isUndefined(window) && !isUndefined(window.Vue)) {
32+
/* istanbul ignore next */
33+
install(window.Vue)
34+
}
35+
}
36+
2837
export default {
2938
version,
3039
install,

0 commit comments

Comments
 (0)