To start our component, we will use the Vue project with Vue-CLI that we used in the 'Creating a dynamic component with Vuex' recipe, or we can start a new one.
To start a new one, open Terminal (macOS or Linux) or Command Prompt/PowerShell (Windows) and execute the following command:
> vue create vuex-store
Choose the manual features, add Router and Vuex as required features, as indicated in the 'How to do it...' section of the 'Creating a simple Vuex store' recipe.
In the following steps, we will add HMR to Vuex:
- Open the index.js file in the src/store folder.
- Transform the export default into a constant called store, and make it exportable:
export const store = new Vuex.Store({
...UserStore,
});
- Check if the webpack hot-module-reload plugin is active:
if (module.hot) {}
- Create a new constant called hmr, which is an array containing the direction to the index.js, getters.js, actions.js, and mutations.js files of the user folder...