How to implement Vuenut in a project vue CLI with webpack 
Tags: vue, javascript, vuex, webdev
Published: 2018-04-19 22:46:27

---
title: How to implement Vuenut in a project vue CLI with webpack 
published: true
description: This library is created to manipulate and visualize the pattern of state management in the case of vuejs (Vuex). The main idea is to facilitate the development and maintenance of data in an application
tags: vuejs, javascript, vuex, webdev
---

<p>
<img src="https://cdn-images-1.medium.com/max/800/1*Se_6x8t0-knOPoRcEfyfqg.png">
</p>

# First of all, what is vuenut?

This library is created to manipulate and visualize the pattern of state management in the case of vuejs (Vuex). The main idea is to facilitate the development and maintenance of data in an application.

<p>

<img src="https://cdn-images-1.medium.com/max/800/1*UcUoC5KMNcHGbILdEfZqMw.gif">
</p>

# Start a project with the new cli 3 de vuejs

As any developer we love the latest, so we are going to implement vuenut in the latest version of the clue of vuejs.

First, if you have no idea what the cli de vue is, check the [Documentacion Oficial](https://github.com/vuejs/vue-cli/blob/dev/docs/README.md)

### Vue CLI

is a full system for rapid Vue.js development, providing:

- Interactive project scaffolding via @vue/cli.
- Zero config rapid prototyping via @vue/cli + @vue/cli-service-global.
- A runtime dependency (@vue/cli-service) that is:
- Upgradeable;
- Built on top of webpack, with sensible defaults;
- Configurable via in-project config file;
- Extensible via plugins
- A rich collection of official plugins integrating the best tools in the frontend ecosystem.


### Iniciar proyecto con vue CLI

Before initial a project with vue CLI we have to install it globally in our machine so that after it can do its magic, for this we execute this command (It does not matter where it is executed because it is installed globally)


     npm install -g @vue/cli


The `-g` command indicates that you must install globally


----

Already with Vue CLI installed

Stop in the folder where you want to add the project (Not the project folder but a before vue CLI creates the folder when starting).

     vue create my-project-vuenut

After executing this command, CLI asks us some questions.

- Please pick a preset: (Use arrow keys)

- Please pick a preset: default (babel, eslint)

you have to wait a while for the installed plugins and dependencies.

At the end of the installation we see a new folder with our project name that in this case is (my-project-vuenut) now if we enter the project that more or less has this structure.


     my-project-vuenut
     - node_modules
     - public
      favicon.ico
      index.html
     - src
     -- assets
     -- components
     App.vue
     main.js
     .gitignore
     package.json
     package-lock

We will execute the command to initial the local server

    npm run serve

# Install and implement Vuenut to the project

Now we have everything ready to implement Vuenut then get to work.

    npm install vuenut

When finished installing vuenut in our project we opened our main file that is (main.js) so that I use the library.

- Add vuenut

To add vuenut we import the already installed dependency and the css styles you need to look great.

    import Vuenut from 'vuenut'
    import 'vuenut/dist/vuenut.css'

And we have Vue use it to add the global level functionality to Vue

    Vue.use(vuenut)

Ready we have vuenut implemented, we just need to add the component within our App.vue file.

- Add the component

To implement vuenut we open the App.vue archovo and within our component.

    <vuenut/>

The App.vue file would remain that way.

    <template>
    <div id="app">
     <vuenut/> <!-- Vuenut component -->
     <img src="./assets/logo.png">
     <HelloWorld msg="Welcome to Your Vue.js App"/>
    </div>
    </template>
    <script>
     import HelloWorld from './components/HelloWorld.vue'
     export default {
      name: 'app',
      components: {
       HelloWorld
      }
    }
    </script>
    <style>
    #app {
     font-family: 'Avenir', Helvetica, Arial, sans-serif;
     -webkit-font-smoothing: antialiased;
     -moz-osx-font-smoothing: grayscale;
     text-align: center;
     color: #2c3e50;
     margin-top: 60px;
    }
    </style>

Ready and we just have to check our local server and see how vuenut is working in so few steps.


<p>
<img src="https://cdn-images-1.medium.com/max/800/1*xe0RAL5jTG7f0ZlSflijbQ.png">
</p>

Vuenut is a library that needs Vuex to work so we can implement vuex in our project and see all the advantages vuenut offers us.

# Install and deploy Vuex

we install the dependence on our project.

    npm install vuex

After finishing the installation, we import and implement.

    import Vuex from 'vuex'
    Vue.use(Vuex)

we already have vuex in the project just missing add it to the vue to have our full store.

    const store = new Vuex.Store({
     state: {
      myName: 'Vuenut'
     },
    })


And we add it to our instance of


    new Vue({
     store,
     render: h => h(App)
    }).$mount('#app')


The App.vue file would be left this way


    import Vue from 'vue'
    import App from './App.vue'
    import Vuenut from 'vuenut'
    import 'vuenut/dist/vuenut.css'
    import Vuex from 'vuex'
    Vue.use(Vuex)
    Vue.use(Vuenut)
    const store = new Vuex.Store({
     state: {
       myName: 'Vuenut'
     },
    })
    Vue.config.productionTip = false
    new Vue({
     store,
    render: h => h(App)
    }).$mount('#app')

Ready we have our store implemented now we are going to add the vuenut.

    <vuenut :store="$store.state"/>

It is important that when adding the store to vuenut let’s put the reference to the state so that everything works perfectly

Ready we have our component with added vuex and it should look like this

<p>
<img src="https://cdn-images-1.medium.com/max/800/1*h39TjuaspkT7trQq4EmUXA.png">
</p>

Excellent we already have vuenut implemented and ready to be used in the project, some things you can do with vuenut.

- Change store data at run time.
- Save the store to use it later and replicate problems or bugs.
- export store in .json to import it later or share it with a project partner.
- Edit the entire store and change the structure of the data at run time.
- Create functions to execute when starting the application or key combination.
All the data of the library is stored in the storage so as not to have to repeat any configuration.
- And many more features.

Vuenut is an open source library, we love to create and keep growing the community.


## Links

- [Vuenut](https://lusaxweb.github.io/vuenut.org/)
- [Github](https://github.com/lusaxweb/vuenut)
- [Vuesax](https://lusaxweb.github.io/vuesax/#/en/home)
- [vuejs](https://vuejs.org/)
- [vuex](https://vuex.vuejs.org/en/)
- [Lusaxweb](http://www.lusaxweb.com.ve/)