Code Monkey home page Code Monkey logo

beauty-vuejs-boilerplate's Introduction

Real World Vue.js Boilerplate

This project based on real world practice and ready to use. Have a fun!

Features

  • Http request class that implements API calls with Auth and tokens refresh based on Axios
  • Data access layer/API calls
  • Response wrapper/Response error wrapper
  • Base common and layout components
  • Some help mixins
  • Vue CLI v4
  • Developed to work with: https://github.com/zmts/supra-api-nodejs

Project structure

src

Source =)

assets

Images/Fonts/Other media stuff.

components

Shared components folder.

  • DataBox wrap in this component any received data. It represents loading(spinloader animation), error and empty statuses (examaple in src/pages/News.vue).
  • UiImgLoader - img tag wrapper. Shows image loading(pulseloader animation) status and animate onloading as option.
  • UiModal - simple modal window.
  • PulseLoading and SpinnerWave - loading animation.
  • UiUploadMulti and UiUploadSingle - file upload example components.
  • ...

config

App config files. Each category in separate file.

directives

  • Handy debounce directive

layout

Base app layout components.

  • Header, Footer components and main layout wrapper.

mixins

  • One method/prop per file principle.
  • Name files same as method/prop.
  • currentUser - Includes current user object from store. Global.
  • formatDateTime - Datetime moment formatters. Global.
  • jumpTo - Help jump to some DOM element. Global.
  • prepareFetchParamsMixin - Prepare params for data fetching (examaple in src/pages/News.vue).
  • prepareQueryParamsMixin - Prepare params for setting it in URL (examaple in src/pages/News.vue).
  • setModelMixin - Use to set same fields from response that declared in front-end model.

pages

Page wrapper components(Pages) and Local components.

plugins

  • globalEventBus - $bus.

router

Router instance and routing declaration.

  • index - router initialization.
  • routes - routing.
  • middlewares:
    • initCurrentUserStateMiddleware - Current user state initialization (each time app loads, check refresh token and fetch current user if token exist.)
    • checkAccessMiddleware - Each time user change route, check permissions to route.
    • setPageTitleMiddleware - Each time user change route, set page title.
  • util:
    • routePropResolver - Pass params from URL to component as props (example in src/router/routes.js)

scss

Style files(partials, variables, mixins, reset).

services

Data access layer/API calls.

  • ES6 API calls classes.
  • API calls must be represented in separate classes (not in vuex action).
  • auth.service - Auth methods and API calls.
  • http.init - Http request class.
  • util:
    • ResponseWrapper - Represent response object.
    • ErrorWrapper - Represent error object.
    • clearData - Uses to clear request data before send it. Helper.

store

App store with separate modules.

.env.js

Environment variables (add this to git ignore).

main.js

Root app initialization file.

How to declare global SCSS variables/mixins etc... ?

In /build/utils.js >> generateLoaders('sass')

Utils/Helpers

What about debounce ?

import debounce from '../directives/debounce'
directives: {
  debounce
}

And use it in a template.

<input type="text" v-model="name" v-debounce="500" @debounce-change="runSomeMethod">

Notifications/Toast:

Just make mutation

commit('dom/TOAST', { message: 'hello', duration: 2000, type: 'success' })

Icons/SVG:

Set up yours svg icons in src/components/icons/ folder. Modify UiIconBase.vue related to yours newly added icons and use it in template.

<UiIconBase size="40" color="yellow" icon="write"/>

Build Setup

# clone repo
git clone https://github.com/zmts/vuejs-boilerplate.git

# install dependencies
npm install

# serve with hot reload at localhost:8080
npm run serve

# build for production with minification
npm run build

For a detailed explanation on how things work, check out the guide and docs for vue-loader.

Amazing repos where I found some great approaches:

!!! Project still in progress !!!

2017 - 2018 - 2019 - 2020 ...

beauty-vuejs-boilerplate's People

Contributors

costacoz avatar zmts avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

beauty-vuejs-boilerplate's Issues

Use Apicase

Hello! I took a look at your services section. To be honest, it looks awful.

I maintain Apicase - it's another library for work with API. Unlike axios, it's much more flexible and has advanced services so you don't need to write tons of boilerplate code.

Now I'm looking for creating some "starter kits" or smth else to show how to organize API in frontend applications (especially in Vue.js applications) with Apicase.

If you want to give it a try, I wrote some posts about using Apicase:

Failed to compile

Hi,

Just to let you know that I tried to install and compiled and it failed :

 v1 git:(master) npm install
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})

audited 1481 packages in 6.223s

48 packages are looking for funding
  run `npm fund` for details

found 931 vulnerabilities (392 low, 197 moderate, 342 high)
  run `npm audit fix` to fix them, or `npm audit` for details


   ╭────────────────────────────────────────────────────────────────╮
   │                                                                │
   │      New major version of npm available! 6.14.10 → 7.20.5      │
   │   Changelog: https://github.com/npm/cli/releases/tag/v7.20.5   │
   │               Run npm install -g npm to update!                │
   │                                                                │
   ╰────────────────────────────────────────────────────────────────╯

v1 git:(master) npm run serve

> [email protected] serve /home/emilie/Devel/FREELANCE/Magali/v1
> NODE_ENV=development vue-cli-service serve

 INFO  Starting development server...
11% building 14/15 modules 1 active ...nt-loader/index.js??ref--13-0!/home/emilie/Devel/FREELANCE/Magali/v1/src/main.jsBrowserslist: caniuse-lite is outdated. Please run the following command: `npm update`
98% after emitting CopyPlugin

 ERROR  Failed to compile with 1 errors                                                                      11:42:06 AM

 error  in ./src/main.js

Module build failed (from ./node_modules/babel-loader/lib/index.js):
Error: [BABEL] /home/emilie/Devel/FREELANCE/Magali/v1/src/main.js: Cannot find module '/home/emilie/Devel/FREELANCE/Magali/v1/node_modules/@babel/compat-data/data/corejs3-shipped-proposals' (While processing: "/home/emilie/Devel/FREELANCE/Magali/v1/node_modules/@vue/cli-plugin-babel/preset.js")
    at createEsmNotFoundErr (internal/modules/cjs/loader.js:842:15)
    at finalizeEsmResolution (internal/modules/cjs/loader.js:835:15)
    at resolveExports (internal/modules/cjs/loader.js:424:14)
    at Function.Module._findPath (internal/modules/cjs/loader.js:464:31)
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:802:27)
    at Function.Module._load (internal/modules/cjs/loader.js:667:27)
    at Module.require (internal/modules/cjs/loader.js:887:19)
    at require (internal/modules/cjs/helpers.js:74:18)
    at Object.<anonymous> (/home/emilie/Devel/FREELANCE/Magali/v1/node_modules/@babel/preset-env/lib/polyfills/corejs3/usage-plugin.js:10:55)
    at Module._compile (internal/modules/cjs/loader.js:999:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
    at Module.load (internal/modules/cjs/loader.js:863:32)
    at Function.Module._load (internal/modules/cjs/loader.js:708:14)
    at Module.require (internal/modules/cjs/loader.js:887:19)
    at require (internal/modules/cjs/helpers.js:74:18)
    at Object.<anonymous> (/home/emilie/Devel/FREELANCE/Magali/v1/node_modules/@babel/preset-env/lib/index.js:29:44)

 @ multi (webpack)-dev-server/client?http://172.28.153.21:8080/sockjs-node (webpack)/hot/dev-server.js ./src/main.js

problem with requiring images dynamically

i'm having this problem that when i require an img based on what i get back from the data base, if the required image is not in my assets it prevents my component to render/re-render and gives me a webpack error .
i want to be able to have a conditional rule for it, like if the required image wasn't there, the component renders normally and the image place become empty or shows a default icon.
is there any solution for that?

my requiring syntax is like this :
<img :src="require(@/assets/icons/${currency.symbol}.png) />
if the ${ingredients.symbol}.png was found in my assets icons folder it shows it . but if it's not it breaks the component!

Is there backend example source?

Thanks for this amazing boilerplate :) really.

i cloned this repo and am looking around.
by the way i found there is no way i can login.
as far as i found it looks like i have to prepare backend server to login, right?

of course i can ignore auth logic but i want to look around backend sever example source either.
can you give me how can i found proper source for backend?

Sorry about my stoopid English ;(

npm run build uglifyjs error

Hi, i'm trying to build my Vue project with "npm run build" command. but i keep getting some error related to UglifyJs -->

ERROR in static/js/vendor.46ca10154a1b16022343.js from UglifyJs
Unexpected token name «i», expected punc «;» [./node_modules/base-x/index.js:15,0][static/js/vendor.46ca10154a1b16022343.js:42282,11]

any idea about what is going on?
any help would be greatly appreciated.

Error: This relative module was not found: * ./SpinnerWave.vue

Hi. Sorry, complete noob here. I've cloned the repo and run npm install and then npm run serve, and I get the following error:

 ERROR  Failed to compile with 1 errors                                                                               16:11:40

This relative module was not found:

* ./SpinnerWave.vue in ./node_modules/cache-loader/dist/cjs.js??ref--12-0!./node_modules/babel-loader/lib!./node_modules/cache
-loader/dist/cjs.js??ref--0-0!./node_modules/vue-loader/lib??vue-loader-options!./src/components/DataBox.vue?vue&type=script&l
ang=js&

Can you help?

License

Hello @zmts , could you please add a license to this repository?
So that we could use code in this repository.
Thank you in advance!

Server-side rendering?

Does/will this support server-side rendering? I really need control over the meta for my pages and that only seems to be possible if the site is SSR.

Css files order on build

Hi. we are encountering an issue , when we build the project using npm run build we face a problem with css ordering at the end . in the project we have a style.css file which has to override all the styles at the end . it works fine in the development mode. but when we build the project using npm run build command , what we see is that some node_module dependency styles are being placed after our style.css styles. how can we prevent that? how can we make sure that our style.css style codes ALWAYS comes last in the process of building our project?

any help will be much appreciated . i know it might not be a boilerplate Direct issue but still , we are facing this problem . thanks in advance .

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.