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
This commit is contained in:
René Eschke
2019-10-11 22:18:43 +02:00
committed by Pavan Kumar Sunkara
parent 3aa513ace5
commit c76091075f
+19
View File
@@ -142,3 +142,22 @@ Now on the page, the user only needs to include Vue and the entry file:
<!-- foo-one's implementation chunk is auto fetched when it's used -->
<foo-one></foo-one>
```
## 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',
// ...
}
```