From 72d7c95eb0e51113650f948f816a7aa33df28cbf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Eschke?= Date: Wed, 22 Aug 2018 12:39:57 +0200 Subject: [PATCH] missing documentation for building with vuex I really needed this tip and luckily got it from this awesome community in a github issue. This definitely needs to be in the docs aswell: https://github.com/vuejs/vue-cli/issues/2304#issuecomment-414702510 --- docs/guide/build-targets.md | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/docs/guide/build-targets.md b/docs/guide/build-targets.md index 04d61a9483..cc065420bd 100644 --- a/docs/guide/build-targets.md +++ b/docs/guide/build-targets.md @@ -130,3 +130,22 @@ Now on the page, the user only needs to include Vue and the entry file: ``` + + +## Using vuex in builds + +When building a [Webcomponent](#web-component) or [Library](#library), the entry point is not `main.js`, but an `entry-wc.js` file, generated here: [https://github.com/vuejs/vue-cli/blob/dev/packages/%40vue/cli-service/lib/commands/build/resolveWcEntry.js](https://github.com/vuejs/vue-cli/blob/dev/packages/%40vue/cli-service/lib/commands/build/resolveWcEntry.js) + +So to use vuex in web component target, you need to initialize the store in `App.vue`: + +``` js +import store from './store' + +// ... + +export default { + store, + name: 'App', + // ... +} +```