My latest project uses Vue.js as a framework, it has a complicated data model so I’m using Vuex, and it needs to be styled using Material Design.
This post details how I created the project.
I am a believer in vue-cli as a starting point to create any Vue project. It saves a lot of configuration time and in a few minutes I can have a working, deployable blank app. There are a number of templates that take care of different types of apps. I’ve used a few of them. I found a vue.js library that implements material design called Vuetify. It has a template that I’ll be using for this example.
One time setup
# to get vue-cli installed:
$ npm i -g vue-cli
For each new project
# Type the following and answer each of the questions below.
$ vue init vuetifyjs/webpack-advanced myproject
? Project name myproject
? Project description My Awesome Project
? Author J. Programmer <email@example.com>
? Vue build standalone
? Install vue-router? Yes
? Use ESLint to lint your code? Yes
? Pick an ESLint preset none
? Setup unit tests with Karma + Mocha? Yes
? Setup e2e tests with Nightwatch? Yes
vue-cli · Generated "myproject".
Store this in source control now!
Now, open the
package.json file and move all the items from
devDependencies, then install the following (you may not need all of these libraries, but most of the apps I work on eventually need them):
$ cd myproject
$ npm install
# for ajax calls
$ npm install --save-dev axios
# for date/time manipulation and formatting
$ npm install --save-dev moment
# for the model layer
$ npm install --save-dev vuex
# for Font Awesome
$ npm install --save-dev vue-awesome
autoOpenBrowser: false. This will keep a new browser session from automatically starting every time you start the dev server. I keep my app open in a browser tab the entire time it is under development, so this would just create duplicates.
.editorconfig, so that it doesn’t cause errors when it doesn’t like your formatting.
devtool: '#inline-source-map'. I was having trouble seeing the correct source code in Chrome without this. I haven’t tried to figure out why.
Go to this site: https://realfavicongenerator.net/ and generate the favicon files. This will result in around a dozen files being generated. Put those files in
index.html, add the code recommended by the favicon generator’s output.
$ npm run dev
Navigate to localhost:8080 to see your app.