A common library for all of Watchout Commons.
# scaffold a new vue project with vue-cli
vue init webpack [project_name]
# add modules to project
npm install node-sass sass-loader --save-dev
npm install jquery tether bootstrap@4.0.0-alpha.6 axios --save
npm install path/to/watchout-tw/common --save-dev
{
"scripts": {
"update": "npm uninstall common; npm i",
"dev": "node build/dev-server.js",
"dev+": "npm uninstall common; npm i; node build/dev-server.js",
...
}
}
module.exports = {
resolve: {
extensions: ['.js', '.vue', '.json'],
alias: {
'vue$': 'vue/dist/vue.esm.js',
'@': resolve('src'), // import ... '@/path/to/thing.js'
'_': resolve('static') // require('_/path/to/img.png')
}
},
module: {
rules: [
{
test: /\.js$/,
loader: 'babel-loader',
include: [resolve('src'), resolve('test'), resolve('node_modules/common')]
},
{
test: /\.(png|jpe?g|gif|svg)(\?.*)?$/,
loader: 'url-loader',
options: {
limit: 100000, // increase limit for small images
name: utils.assetsPath('img/[name].[hash:7].[ext]')
}
},
...
]
}
}
module.exports = {
build: {
index: path.resolve(__dirname, '../docs/index.html'),
assetsRoot: path.resolve(__dirname, '../docs'),
...
assetsPublicPath: './', // for test run on localhost
...
},
dev: {
autoOpenBrowser: false,
...
}
}
module.exports = {
rules: {
...
'space-before-function-paren': 0,
'keyword-spacing': 0,
'no-new': 0
}
}
import $ from 'jquery'
global.$ = window.jQuery = window.$ = require('jquery')
global.Tether = require('tether')
global.Bootstrap = require('bootstrap')
import axios from 'axios'
import dataStore from 'common/src/lib/dataStore'
with
<style lang="scss">
@import '~common/src/styles/resources';
# install dependencies
npm i
# serve with hot reload at localhost:4200
npm run dev
# run unit tests
npm run unit
# run all tests
npm test
For detailed explanation on how things work, checkout the guide and docs for vue-loader.
use to check if token is stored in browser
import * as util from 'common/src/lib/util'
var isTokened = util.jwtTokenIsHere()