Vue 2 Boilerplate for Developing Medium to Large Single Page Applications


A boilerplate for building medium to large Vue 2 single-page applications

This boilerplate is based on the Vue webpack template. Common topics are discussed in the VueJS docs. Make sure to read it!


To get up and running run:

$ yarn
$ yarn serve

Yes, that’s it. Only two commands!

If you still think that’s too much effort, you could also run:

$ yarn && yarn serve

But yeah, this will basically do the same as yarn. If even this is too much of a deal, try creating an alias and bind yarn && yarn serve to yarn:serve.


Wait a minute, you just said that I only need to run yarn? What’s this? Do I need to do more?

Yeah, to get up and running real quick, yarn is enough. But if you want to, let’s say, connect to an external API, there’s a little bit more involved. You need to configure your application a bit more, explained below:

Environment variables

In the root of the boilerplate is a predefined environment file. Copy the file and name it .env or a configuration specific file like For more information, visit the docs.

What’s included

  • yarn serve: first-in-class development experience.
  • yarn build: production-ready build.
  • yarn unit: start the Karma Test Runner.
  • yarn e2e: start the Nightwatch Test Runner.
  • yarn lint: lint the files using ESLint.

Important Files

So there are two important files that need to be addressed:


This file will load your single page application and bootstrap all the plugins that are used. It will also serve as the entry point which will be loaded and compiled using webpack.


The main Vue file. This file will load the page inside the router-view-component. It will check if the user is authenticated and load the resources accordingly.

Directory Structure

Inside the src-directory, are a couple of directories that need to be addressed:


The assets that you want to use are placed inside this directory. This can be images, stylesheets, videos… you name it.


Your components will be placed inside this directory. As you can see, this boilerplate comes already shipped with a pre-made card component.


Your layout files will be placed inside this directory. When you are building a large single page application, you will be using different layouts. For instance, your login-page or register-page will have a different layout than your account-page.

The boilerplate comes out of the box with two layouts included. A minimal layout, used for the login and register page, and a default layout, used for the home and account page.


The Vue I18n plugin is used for localization. In the locale directory, you’ll find an example for internalization. This boilerplate comes with examples for English and Dutch out of the box, but feel free to add more!


The mixins you want to use with Vue will be placed inside this directory.

Inside the mixins directory is a slot-mixin. This mixin will add the hasSlot()-method to all the components it is used in.


This boilerplate comes with a couple of plugins you can use. It will load and configure:

  • axios
  • bootstrap
  • font-awesome
  • vue-i18n
  • vue-router
  • vuex
  • vuex-router-sync

Don’t like one of those plugins? Just remove the file from the plugins-directory and remove the entry from the main.js-file. Also, make sure to remove the package and dependencies from the package.json-file.


Proxies are used to perform AJAX-requests. This boilerplate comes with a base proxy which can be used to make performing AJAX-requests fairly easy. Create a new proxy, for example, UserProxy, and extend the Proxy. This way you’ve got access to the all, find, update, create and destroy methods. The boilerplate comes with an AccountProxy and AuthProxy by default.


In this directory, you can specify the routes that are used by this application. Vue Router loads the routes located in this directory.


As mentioned before, Vuex is used as a single point of truth. To learn more about Vuex, visit the documentation


Transformers are used to transform the incoming and outgoing requests. If you have an API where you can retrieve posts from, a post will look something like this:

  "id" : 1,
  "title" : "Hello World!",
  "content" : "Lorem Ipsum",
  "created_at" : "today"

However, it feels weird to use snake_cased variables inside your camelCased application. This is where transformers come in. So given the previous example, using a transformer, it will look something like this:

  "id" : 1,
  "title" : "Hello World!",
  "content" : "Lorem Ipsum",
  "createdAt" : "today"


Here you can place handy utils you want to use inside your application.


The pages are placed inside this directory. By default it comes with an Account/Index.vue, Home/Index.vue, Login/Index.vue and a Register/Index.vue page, but feel free to add more.


Both the Unit Tests and the End-2-End Tests are within the test/ folder. Unit Tests should go inside the test/unit/specs folder. E2e Tests should go inside the test/e2e/specs folder. You can read more about both tests on the Webpack Boilerplate Testing Session.

Got questions or improvements?

Feel free to hit me up on:

Or create an issue

Fork It And Make Your Own

What are you waiting for?! Make something awesome!

Download Details:

Author: petervmeijgaard

Source Code:

#vue #vuejs #javascript

Vue 2 Boilerplate for Developing Medium to Large Single Page Applications
33.45 GEEK