From c76091075ffa2cf5a3bc4414d7bfe12314b9e4e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Eschke?= Date: Fri, 11 Oct 2019 22:18:43 +0200 Subject: [PATCH] missing documentation for building with vuex (#2319) 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 e3aa1bf965..064c19b7f2 100644 --- a/docs/guide/build-targets.md +++ b/docs/guide/build-targets.md @@ -142,3 +142,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', + // ... +} +```