this project is made for passing my significant time in wasting, but in a funny way π
npm install
npm run serve
npm run build
npm run test
npm run lint
npm run test:e2e
npm run test:unit
By Sandoche Adittane. sorry Adittane, I couldn't take your permission before using your article for time being. π΄
you may read actual article in this url.
.
βββ app.css
βββ App.vue
βββ assets
β βββ ...
βββ components
β βββ ...
βββ main.js
βββ mixins
β βββ ...
βββ router
β βββ index.js
βββ store
β βββ index.js
β βββ modules
β β βββ ...
β βββ mutation-types.js
βββ translations
β βββ index.js
βββ utils
β βββ ...
βββ views
βββ ...
A few details about each of these folders:
- assets β Where you put any assets that are imported into your components
- components β All the components of the projects that are not the main views
- mixins β The mixins are the parts of javascript code that is reused in different components. In a mixin you can put any componentβs methods from Vue.js they will be merged with the ones of the component that uses it.
- router β All the routes of your projects (in my case I have them in the index.js). Basically in Vue.js everything is a component. But not everything is a page. A page has a route like β/dashboardβ, β/settingsβ or β/searchβ. If a component has a route it is routed.
- store (optional) β The Vuex constants in mutation-type.js, the Vuex modules in the subfolder modules (which are then loaded in the index.js).
- translations (optional) β Locales files, I use Vue-i18n, and it works pretty good.
- utils (optional) β Functions that I use in some components, such as regex value testing, constants or filters.
- views β To make the project faster to read I separate the components that are routed and put them in this folder. The components that are routed for me are more than a component since they represent pages and they have routes, I put them in βviewsβ then when you check a page you go to this folder. You can eventually add other folders depending on your need such as filters,or constants, API.
Here are a few conventions coming from the Vue.js official styleguide that you need to structure well your project:
- Component names should always be multi-word, except for root βAppβ components. Use βUserCardβ or βProfileCardβ instead of βCardβ for example.
- Each component should be in its own file.
- Filenames of single-file components should either be always PascalCase or always kebab-case. Use βUserCard.vueβ or βuser-card.vueβ.
- Components that are only used once per page should begin with the prefix βTheβ, to denote that there can be only one. For example for a navbar or a footer you should use βTheNavbar.vueβ or βTheFooter.vueβ.
- Child components should include their parent name as a prefix. For example if you would like a βPhotoβ component used in the βUserCardβ you will name it βUserCardPhotoβ. Itβs for better readability since files in a folder are usually order alphabetically.
- Always use full name instead of abbreviation in the name of your components. For example donβt use βUDSettingsβ, use instead βUserDashboardSettingsβ.