@johnnywang/vuex-loader

1.0.3 • Public • Published

vuex-loader

This plugin is a webpack-loader, which could only be set in your webpack condig file, a new runtime compile version has be published

Please refer to: Vuexess

This is a simple webpack loader which helps import vuex data without using any mapState, mapActions...

Install

$ npm install @johnnywang/vuex-loader

then just use right below(which will load before) your webpack's vue-loader:

it will automatically import all the vuex data you want to each components.

module.exports = {
  modules: {
    test: /\.vue$/,
    loader: [
      'vue-loader',
      '@johnnywang/vuex-loader',
    ],
  },
}

Usage

Use vuex option in each vue component:

No matter vuex or Vuex, it is case-insensitive.

export default {
  name: 'SampleComponent',
  vuex: {
    state: ['profile', 'todoList'],
    actions: ['getProfile', 'getTodos'],
    Login: {
      state: ['loginStatus'],
      actions: ['postLogin'],
    }
  },
};

Params in vuex options

moduleName below is the module name which you had registered in your vuex.

this plugin will not check anything, which totally relys on vuex. so totally without any side effect.

Param Type Description
state array or object rootState of vuex
getters array or object rootGetters of vuex
mutations array or object rootMutations of vuex
actions array or object rootActions of vuex
moduleName object modules registered in vuex

License

MIT

Copyright (c) 2020-present, Johnny Wang

Readme

Keywords

none

Package Sidebar

Install

npm i @johnnywang/vuex-loader

Weekly Downloads

1

Version

1.0.3

License

MIT

Unpacked Size

5.96 kB

Total Files

7

Last publish

Collaborators

  • johnnywang