I am trying to make a component library that will be shared across several apps. Each app is internal to a larger global app and has their own domain.
hub.website.com
app.website.com
The component library uses Vuex to allow users to change their preferences(Ex: want to increase the button size or change it's color).
In my components library project i created the index.js file which is the main file
//index.js
import * as vsComponents from './components' // imports all the components
import storeModule from './store/components' //Imports the store module which is mentioned below
const install = (Vue, options = {}) => {
if (!options.store) { //Must pass the store from the larger component
throw new Error('Please provide vuex store.')
}
//Register Store modules
options.store.registerModule('components', storeModule) //Registers the module into the larger store
// Use Components
Object.values(vsComponents).forEach(vsComponent => { //Creates the components for vue to use
Vue.use(vsComponent)
})
}
if (typeof window !== 'undefined' && window.Vue) { //No 100% sure i need this ??? - i would like it ssr so im thinking its not required (any help here would be awesome too)
install(window.Vue)
}
export default install
export * from './components/index' //Allows you to individually import each component
I use the following command to create the component library and upload it to bitbucket "scripts":{"production": "vue-cli-service build --target lib --name sc src/index.js"} in which src/index.js is the file with the code pasted above.
In my nuxt application, i
Here my components.js file
import components from 'components' //Component library
import Vue from 'vue'
export default context => {
Vue.use(components, { store: context.store })
}
The Funny part
On the initial load of the page, i can see the added state from the components library
<pre> {{ this.$store.state.components }} </pre>
When i refresh the page, the added state is now gone?!?!?!
TLDR Basically, i am importing a component lirbary as a plugin within nuxt. On the initial load, the plugin works as expect by injecting it's vuex module parameters into the nuxt's store. Upon subsequent loads, the vuex module is gone???
Essentially, all im trying to do is have the a basic store module held within the components library. This would keep everything consistent between apps and then add the module to the larger app store and be able to utilize/use it
Hello, thank you for taking time filling this issue!
However, we kindly ask you to use our Issue Helper when creating new issues, in order to ensure every issue provides the necessary information for us to investigate. This explains why your issue has been automatically closed by me (your robot friend!).
I hope to see your helper-created issue very soon!
stupid fucking @vue-bot
Most helpful comment
stupid fucking @vue-bot