├── .babelrc
├── .editorconfig
├── .eslintignore
├── .eslintrc.js
├── .gitignore
├── .postcssrc.js
├── README.md
├── build
├── build.js
├── check-versions.js
├── dev-client.js
├── dev-server.js
├── utils.js
├── vue-loader.conf.js
├── webpack.base.conf.js
├── webpack.dev.conf.js
├── webpack.prod.conf.js
└── webpack.test.conf.js
├── config
├── dev.env.js
├── index.js
├── prod.env.js
└── test.env.js
├── index.html
├── package.json
├── src
├── App.vue
├── api
│ └── index.js
├── assets
│ ├── awesome-vue.png
│ ├── github.svg
│ └── logo.png
├── components
│ ├── FormGroup.vue
│ ├── Hello.vue
│ ├── LoginForm.vue
│ ├── Modal.vue
│ ├── Navbar.vue
│ ├── Toastr.vue
│ └── index.js
├── directives
│ ├── dropdown.js
│ └── index.js
├── filters
│ └── index.js
├── locales
│ └── index.js
├── main.js
├── mixins
│ └── index.js
├── plugins
│ ├── component.js
│ ├── index.js
│ ├── modal.js
│ └── toastr.js
├── router
│ ├── index.js
│ ├── routes.js
│ └── transition.less
├── store
│ ├── index.js
│ └── modules
│ │ ├── account.js
│ │ └── auth.js
├── theme
│ └── default.less
├── utils
│ └── index.js
├── validators
│ └── index.js
└── views
│ ├── Account
│ └── Profile.vue
│ ├── Auth
│ ├── Login.vue
│ └── Register.vue
│ ├── Empty.vue
│ └── Home
│ ├── Jumbotron.vue
│ └── index.vue
├── static
├── .gitkeep
└── loading.svg
└── test
├── e2e
├── custom-assertions
│ └── elementCount.js
├── nightwatch.conf.js
├── runner.js
└── specs
│ └── test.js
└── unit
├── .eslintrc
├── index.js
├── karma.conf.js
└── specs
└── Hello.spec.js
/.babelrc:
--------------------------------------------------------------------------------
1 | {
2 | "presets": [
3 | ["env", {
4 | "modules": false,
5 | "targets": {
6 | "browsers": ["> 1%", "last 2 versions", "not ie <= 8"]
7 | }
8 | }],
9 | "stage-2"
10 | ],
11 | "plugins": ["transform-runtime"],
12 | "env": {
13 | "test": {
14 | "presets": ["env", "stage-2"],
15 | "plugins": ["istanbul"]
16 | }
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/.editorconfig:
--------------------------------------------------------------------------------
1 | root = true
2 |
3 | [*]
4 | charset = utf-8
5 | indent_style = space
6 | indent_size = 2
7 | end_of_line = lf
8 | insert_final_newline = true
9 | trim_trailing_whitespace = true
10 |
--------------------------------------------------------------------------------
/.eslintignore:
--------------------------------------------------------------------------------
1 | build/*.js
2 | config/*.js
3 |
--------------------------------------------------------------------------------
/.eslintrc.js:
--------------------------------------------------------------------------------
1 | // https://eslint.org/docs/user-guide/configuring
2 |
3 | module.exports = {
4 | root: true,
5 | parser: 'babel-eslint',
6 | parserOptions: {
7 | sourceType: 'module'
8 | },
9 | env: {
10 | browser: true,
11 | },
12 | // https://github.com/standard/standard/blob/master/docs/RULES-en.md
13 | extends: 'standard',
14 | // required to lint *.vue files
15 | plugins: [
16 | 'html'
17 | ],
18 | // add your custom rules here
19 | 'rules': {
20 | // allow paren-less arrow functions
21 | 'arrow-parens': 0,
22 | // allow async-await
23 | 'generator-star-spacing': 0,
24 | // allow debugger during development
25 | 'no-debugger': process.env.NODE_ENV === 'production' ? 2 : 0
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | .DS_Store
2 | node_modules/
3 | dist/
4 | npm-debug.log*
5 | yarn-debug.log*
6 | yarn-error.log*
7 | test/unit/coverage
8 | test/e2e/reports
9 | selenium-debug.log
10 |
11 | # Editor directories and files
12 | .idea
13 | .vscode
14 | *.suo
15 | *.ntvs*
16 | *.njsproj
17 | *.sln
18 |
--------------------------------------------------------------------------------
/.postcssrc.js:
--------------------------------------------------------------------------------
1 | // https://github.com/michael-ciniawsky/postcss-load-config
2 |
3 | module.exports = {
4 | "plugins": {
5 | // to edit target browsers: use "browserslist" field in package.json
6 | "autoprefixer": {}
7 | }
8 | }
9 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # vue-boilerplate
2 |
3 | > Vue 2.0 boilerplate,based on webpack and es6,includes vuex,vue-router,vue-resource, vuelidate
4 |
5 | ## Demo
6 |
7 | [vue-boilerplate demo](https://millerren.github.io/vue-boilerplate/)
8 |
9 | ## Build Setup
10 |
11 | ``` bash
12 | # install dependencies
13 | npm install
14 |
15 | # serve with hot reload at localhost:8080
16 | npm run dev
17 |
18 | # build for production with minification
19 | npm run build
20 |
21 | # run unit tests
22 | npm run unit
23 |
24 | # run e2e tests
25 | npm run e2e
26 |
27 | # run all tests
28 | npm test
29 |
30 | # publish
31 | npm version patch | minor | major
32 | ```
33 |
34 | For detailed explanation on how things work, checkout the [guide](http://vuejs-templates.github.io/webpack/) and [docs for vue-loader](http://vuejs.github.io/vue-loader).
35 |
--------------------------------------------------------------------------------
/build/build.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 | require('./check-versions')()
3 |
4 | process.env.NODE_ENV = 'production'
5 |
6 | const ora = require('ora')
7 | const rm = require('rimraf')
8 | const path = require('path')
9 | const chalk = require('chalk')
10 | const webpack = require('webpack')
11 | const config = require('../config')
12 | const webpackConfig = require('./webpack.prod.conf')
13 |
14 | const spinner = ora('building for production...')
15 | spinner.start()
16 |
17 | rm(path.join(config.build.assetsRoot, config.build.assetsSubDirectory), err => {
18 | if (err) throw err
19 | webpack(webpackConfig, function (err, stats) {
20 | spinner.stop()
21 | if (err) throw err
22 | process.stdout.write(stats.toString({
23 | colors: true,
24 | modules: false,
25 | children: false,
26 | chunks: false,
27 | chunkModules: false
28 | }) + '\n\n')
29 |
30 | if (stats.hasErrors()) {
31 | console.log(chalk.red(' Build failed with errors.\n'))
32 | process.exit(1)
33 | }
34 |
35 | console.log(chalk.cyan(' Build complete.\n'))
36 | console.log(chalk.yellow(
37 | ' Tip: built files are meant to be served over an HTTP server.\n' +
38 | ' Opening index.html over file:// won\'t work.\n'
39 | ))
40 | })
41 | })
42 |
--------------------------------------------------------------------------------
/build/check-versions.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 | const chalk = require('chalk')
3 | const semver = require('semver')
4 | const packageConfig = require('../package.json')
5 | const shell = require('shelljs')
6 | function exec (cmd) {
7 | return require('child_process').execSync(cmd).toString().trim()
8 | }
9 |
10 | const versionRequirements = [
11 | {
12 | name: 'node',
13 | currentVersion: semver.clean(process.version),
14 | versionRequirement: packageConfig.engines.node
15 | }
16 | ]
17 |
18 | if (shell.which('npm')) {
19 | versionRequirements.push({
20 | name: 'npm',
21 | currentVersion: exec('npm --version'),
22 | versionRequirement: packageConfig.engines.npm
23 | })
24 | }
25 |
26 | module.exports = function () {
27 | const warnings = []
28 | for (let i = 0; i < versionRequirements.length; i++) {
29 | const mod = versionRequirements[i]
30 | if (!semver.satisfies(mod.currentVersion, mod.versionRequirement)) {
31 | warnings.push(mod.name + ': ' +
32 | chalk.red(mod.currentVersion) + ' should be ' +
33 | chalk.green(mod.versionRequirement)
34 | )
35 | }
36 | }
37 |
38 | if (warnings.length) {
39 | console.log('')
40 | console.log(chalk.yellow('To use this template, you must update following to modules:'))
41 | console.log()
42 | for (let i = 0; i < warnings.length; i++) {
43 | const warning = warnings[i]
44 | console.log(' ' + warning)
45 | }
46 | console.log()
47 | process.exit(1)
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/build/dev-client.js:
--------------------------------------------------------------------------------
1 | /* eslint-disable */
2 | 'use strict'
3 | require('eventsource-polyfill')
4 | var hotClient = require('webpack-hot-middleware/client?noInfo=true&reload=true')
5 |
6 | hotClient.subscribe(function (event) {
7 | if (event.action === 'reload') {
8 | window.location.reload()
9 | }
10 | })
11 |
--------------------------------------------------------------------------------
/build/dev-server.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 | require('./check-versions')()
3 |
4 | const config = require('../config')
5 | if (!process.env.NODE_ENV) {
6 | process.env.NODE_ENV = JSON.parse(config.dev.env.NODE_ENV)
7 | }
8 |
9 | const opn = require('opn')
10 | const path = require('path')
11 | const express = require('express')
12 | const webpack = require('webpack')
13 | const proxyMiddleware = require('http-proxy-middleware')
14 | const webpackConfig = (process.env.NODE_ENV === 'testing' || process.env.NODE_ENV === 'production')
15 | ? require('./webpack.prod.conf')
16 | : require('./webpack.dev.conf')
17 |
18 | // default port where dev server listens for incoming traffic
19 | const port = process.env.PORT || config.dev.port
20 | // automatically open browser, if not set will be false
21 | const autoOpenBrowser = !!config.dev.autoOpenBrowser
22 | // Define HTTP proxies to your custom API backend
23 | // https://github.com/chimurai/http-proxy-middleware
24 | const proxyTable = config.dev.proxyTable
25 |
26 | const app = express()
27 | const compiler = webpack(webpackConfig)
28 |
29 | const devMiddleware = require('webpack-dev-middleware')(compiler, {
30 | publicPath: webpackConfig.output.publicPath,
31 | quiet: true
32 | })
33 |
34 | const hotMiddleware = require('webpack-hot-middleware')(compiler, {
35 | log: false,
36 | heartbeat: 2000
37 | })
38 | // force page reload when html-webpack-plugin template changes
39 | // currently disabled until this is resolved:
40 | // https://github.com/jantimon/html-webpack-plugin/issues/680
41 | // compiler.plugin('compilation', function (compilation) {
42 | // compilation.plugin('html-webpack-plugin-after-emit', function (data, cb) {
43 | // hotMiddleware.publish({ action: 'reload' })
44 | // cb()
45 | // })
46 | // })
47 |
48 | // enable hot-reload and state-preserving
49 | // compilation error display
50 | app.use(hotMiddleware)
51 |
52 | // proxy api requests
53 | Object.keys(proxyTable).forEach(function (context) {
54 | let options = proxyTable[context]
55 | if (typeof options === 'string') {
56 | options = { target: options }
57 | }
58 | app.use(proxyMiddleware(options.filter || context, options))
59 | })
60 |
61 | // handle fallback for HTML5 history API
62 | app.use(require('connect-history-api-fallback')())
63 |
64 | // serve webpack bundle output
65 | app.use(devMiddleware)
66 |
67 | // serve pure static assets
68 | const staticPath = path.posix.join(config.dev.assetsPublicPath, config.dev.assetsSubDirectory)
69 | app.use(staticPath, express.static('./static'))
70 |
71 | const uri = 'http://localhost:' + port
72 |
73 | var _resolve
74 | var _reject
75 | var readyPromise = new Promise((resolve, reject) => {
76 | _resolve = resolve
77 | _reject = reject
78 | })
79 |
80 | var server
81 | var portfinder = require('portfinder')
82 | portfinder.basePort = port
83 |
84 | console.log('> Starting dev server...')
85 | devMiddleware.waitUntilValid(() => {
86 | portfinder.getPort((err, port) => {
87 | if (err) {
88 | _reject(err)
89 | }
90 | process.env.PORT = port
91 | var uri = 'http://localhost:' + port
92 | console.log('> Listening at ' + uri + '\n')
93 | // when env is testing, don't need open it
94 | if (autoOpenBrowser && process.env.NODE_ENV !== 'testing') {
95 | opn(uri)
96 | }
97 | server = app.listen(port)
98 | _resolve()
99 | })
100 | })
101 |
102 | module.exports = {
103 | ready: readyPromise,
104 | close: () => {
105 | server.close()
106 | }
107 | }
108 |
--------------------------------------------------------------------------------
/build/utils.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 | const path = require('path')
3 | const config = require('../config')
4 | const ExtractTextPlugin = require('extract-text-webpack-plugin')
5 |
6 | exports.assetsPath = function (_path) {
7 | const assetsSubDirectory = process.env.NODE_ENV === 'production'
8 | ? config.build.assetsSubDirectory
9 | : config.dev.assetsSubDirectory
10 | return path.posix.join(assetsSubDirectory, _path)
11 | }
12 |
13 | exports.cssLoaders = function (options) {
14 | options = options || {}
15 |
16 | const cssLoader = {
17 | loader: 'css-loader',
18 | options: {
19 | minimize: process.env.NODE_ENV === 'production',
20 | sourceMap: options.sourceMap
21 | }
22 | }
23 |
24 | // generate loader string to be used with extract text plugin
25 | function generateLoaders (loader, loaderOptions) {
26 | const loaders = [cssLoader]
27 | if (loader) {
28 | loaders.push({
29 | loader: loader + '-loader',
30 | options: Object.assign({}, loaderOptions, {
31 | sourceMap: options.sourceMap
32 | })
33 | })
34 | }
35 |
36 | // Extract CSS when that option is specified
37 | // (which is the case during production build)
38 | if (options.extract) {
39 | return ExtractTextPlugin.extract({
40 | use: loaders,
41 | fallback: 'vue-style-loader'
42 | })
43 | } else {
44 | return ['vue-style-loader'].concat(loaders)
45 | }
46 | }
47 |
48 | // https://vue-loader.vuejs.org/en/configurations/extract-css.html
49 | return {
50 | css: generateLoaders(),
51 | postcss: generateLoaders(),
52 | less: generateLoaders('less'),
53 | sass: generateLoaders('sass', { indentedSyntax: true }),
54 | scss: generateLoaders('sass'),
55 | stylus: generateLoaders('stylus'),
56 | styl: generateLoaders('stylus')
57 | }
58 | }
59 |
60 | // Generate loaders for standalone style files (outside of .vue)
61 | exports.styleLoaders = function (options) {
62 | const output = []
63 | const loaders = exports.cssLoaders(options)
64 | for (const extension in loaders) {
65 | const loader = loaders[extension]
66 | output.push({
67 | test: new RegExp('\\.' + extension + '$'),
68 | use: loader
69 | })
70 | }
71 | return output
72 | }
73 |
--------------------------------------------------------------------------------
/build/vue-loader.conf.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 | const utils = require('./utils')
3 | const config = require('../config')
4 | const isProduction = process.env.NODE_ENV === 'production'
5 |
6 | module.exports = {
7 | loaders: utils.cssLoaders({
8 | sourceMap: isProduction
9 | ? config.build.productionSourceMap
10 | : config.dev.cssSourceMap,
11 | extract: isProduction
12 | }),
13 | transformToRequire: {
14 | video: 'src',
15 | source: 'src',
16 | img: 'src',
17 | image: 'xlink:href'
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/build/webpack.base.conf.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 | const path = require('path')
3 | const utils = require('./utils')
4 | const config = require('../config')
5 | const vueLoaderConfig = require('./vue-loader.conf')
6 |
7 | function resolve (dir) {
8 | return path.join(__dirname, '..', dir)
9 | }
10 |
11 | module.exports = {
12 | entry: {
13 | app: './src/main.js'
14 | },
15 | output: {
16 | path: config.build.assetsRoot,
17 | filename: '[name].js',
18 | publicPath: process.env.NODE_ENV === 'production'
19 | ? config.build.assetsPublicPath
20 | : config.dev.assetsPublicPath
21 | },
22 | resolve: {
23 | extensions: ['.js', '.vue', '.json'],
24 | alias: {
25 | 'vue$': 'vue/dist/vue.esm.js',
26 | '@': resolve('src'),
27 | }
28 | },
29 | module: {
30 | rules: [
31 | {
32 | test: /\.(js|vue)$/,
33 | loader: 'eslint-loader',
34 | enforce: 'pre',
35 | include: [resolve('src'), resolve('test')],
36 | options: {
37 | formatter: require('eslint-friendly-formatter')
38 | }
39 | },
40 | {
41 | test: /\.vue$/,
42 | loader: 'vue-loader',
43 | options: vueLoaderConfig
44 | },
45 | {
46 | test: /\.js$/,
47 | loader: 'babel-loader',
48 | include: [resolve('src'), resolve('test')]
49 | },
50 | {
51 | test: /\.(png|jpe?g|gif|svg)(\?.*)?$/,
52 | loader: 'url-loader',
53 | options: {
54 | limit: 10000,
55 | name: utils.assetsPath('img/[name].[hash:7].[ext]')
56 | }
57 | },
58 | {
59 | test: /\.(mp4|webm|ogg|mp3|wav|flac|aac)(\?.*)?$/,
60 | loader: 'url-loader',
61 | options: {
62 | limit: 10000,
63 | name: utils.assetsPath('media/[name].[hash:7].[ext]')
64 | }
65 | },
66 | {
67 | test: /\.(woff2?|eot|ttf|otf)(\?.*)?$/,
68 | loader: 'url-loader',
69 | options: {
70 | limit: 10000,
71 | name: utils.assetsPath('fonts/[name].[hash:7].[ext]')
72 | }
73 | }
74 | ]
75 | }
76 | }
77 |
--------------------------------------------------------------------------------
/build/webpack.dev.conf.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 | const utils = require('./utils')
3 | const webpack = require('webpack')
4 | const config = require('../config')
5 | const merge = require('webpack-merge')
6 | const baseWebpackConfig = require('./webpack.base.conf')
7 | const HtmlWebpackPlugin = require('html-webpack-plugin')
8 | const FriendlyErrorsPlugin = require('friendly-errors-webpack-plugin')
9 |
10 | // add hot-reload related code to entry chunks
11 | Object.keys(baseWebpackConfig.entry).forEach(function (name) {
12 | baseWebpackConfig.entry[name] = ['./build/dev-client'].concat(baseWebpackConfig.entry[name])
13 | })
14 |
15 | module.exports = merge(baseWebpackConfig, {
16 | module: {
17 | rules: utils.styleLoaders({ sourceMap: config.dev.cssSourceMap })
18 | },
19 | // cheap-module-eval-source-map is faster for development
20 | devtool: '#cheap-module-eval-source-map',
21 | plugins: [
22 | new webpack.DefinePlugin({
23 | 'process.env': config.dev.env
24 | }),
25 | // https://github.com/glenjamin/webpack-hot-middleware#installation--usage
26 | new webpack.HotModuleReplacementPlugin(),
27 | new webpack.NoEmitOnErrorsPlugin(),
28 | // https://github.com/ampedandwired/html-webpack-plugin
29 | new HtmlWebpackPlugin({
30 | filename: 'index.html',
31 | template: 'index.html',
32 | inject: true
33 | }),
34 | new FriendlyErrorsPlugin()
35 | ]
36 | })
37 |
--------------------------------------------------------------------------------
/build/webpack.prod.conf.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 | const path = require('path')
3 | const utils = require('./utils')
4 | const webpack = require('webpack')
5 | const config = require('../config')
6 | const merge = require('webpack-merge')
7 | const baseWebpackConfig = require('./webpack.base.conf')
8 | const CopyWebpackPlugin = require('copy-webpack-plugin')
9 | const HtmlWebpackPlugin = require('html-webpack-plugin')
10 | const ExtractTextPlugin = require('extract-text-webpack-plugin')
11 | const OptimizeCSSPlugin = require('optimize-css-assets-webpack-plugin')
12 |
13 | const env = process.env.NODE_ENV === 'testing'
14 | ? require('../config/test.env')
15 | : config.build.env
16 |
17 | const webpackConfig = merge(baseWebpackConfig, {
18 | module: {
19 | rules: utils.styleLoaders({
20 | sourceMap: config.build.productionSourceMap,
21 | extract: true
22 | })
23 | },
24 | devtool: config.build.productionSourceMap ? '#source-map' : false,
25 | output: {
26 | path: config.build.assetsRoot,
27 | filename: utils.assetsPath('js/[name].[chunkhash].js'),
28 | chunkFilename: utils.assetsPath('js/[id].[chunkhash].js')
29 | },
30 | plugins: [
31 | // http://vuejs.github.io/vue-loader/en/workflow/production.html
32 | new webpack.DefinePlugin({
33 | 'process.env': env
34 | }),
35 | // UglifyJs do not support ES6+, you can also use babel-minify for better treeshaking: https://github.com/babel/minify
36 | new webpack.optimize.UglifyJsPlugin({
37 | compress: {
38 | warnings: false
39 | },
40 | sourceMap: true
41 | }),
42 | // extract css into its own file
43 | new ExtractTextPlugin({
44 | filename: utils.assetsPath('css/[name].[contenthash].css')
45 | }),
46 | // Compress extracted CSS. We are using this plugin so that possible
47 | // duplicated CSS from different components can be deduped.
48 | new OptimizeCSSPlugin({
49 | cssProcessorOptions: {
50 | safe: true
51 | }
52 | }),
53 | // generate dist index.html with correct asset hash for caching.
54 | // you can customize output by editing /index.html
55 | // see https://github.com/ampedandwired/html-webpack-plugin
56 | new HtmlWebpackPlugin({
57 | filename: process.env.NODE_ENV === 'testing'
58 | ? 'index.html'
59 | : config.build.index,
60 | template: 'index.html',
61 | inject: true,
62 | minify: {
63 | removeComments: true,
64 | collapseWhitespace: true,
65 | removeAttributeQuotes: true
66 | // more options:
67 | // https://github.com/kangax/html-minifier#options-quick-reference
68 | },
69 | // necessary to consistently work with multiple chunks via CommonsChunkPlugin
70 | chunksSortMode: 'dependency'
71 | }),
72 | // keep module.id stable when vender modules does not change
73 | new webpack.HashedModuleIdsPlugin(),
74 | // split vendor js into its own file
75 | new webpack.optimize.CommonsChunkPlugin({
76 | name: 'vendor',
77 | minChunks: function (module) {
78 | // any required modules inside node_modules are extracted to vendor
79 | return (
80 | module.resource &&
81 | /\.js$/.test(module.resource) &&
82 | module.resource.indexOf(
83 | path.join(__dirname, '../node_modules')
84 | ) === 0
85 | )
86 | }
87 | }),
88 | // extract webpack runtime and module manifest to its own file in order to
89 | // prevent vendor hash from being updated whenever app bundle is updated
90 | new webpack.optimize.CommonsChunkPlugin({
91 | name: 'manifest',
92 | chunks: ['vendor']
93 | }),
94 | // copy custom static assets
95 | new CopyWebpackPlugin([
96 | {
97 | from: path.resolve(__dirname, '../static'),
98 | to: config.build.assetsSubDirectory,
99 | ignore: ['.*']
100 | }
101 | ])
102 | ]
103 | })
104 |
105 | if (config.build.productionGzip) {
106 | const CompressionWebpackPlugin = require('compression-webpack-plugin')
107 |
108 | webpackConfig.plugins.push(
109 | new CompressionWebpackPlugin({
110 | asset: '[path].gz[query]',
111 | algorithm: 'gzip',
112 | test: new RegExp(
113 | '\\.(' +
114 | config.build.productionGzipExtensions.join('|') +
115 | ')$'
116 | ),
117 | threshold: 10240,
118 | minRatio: 0.8
119 | })
120 | )
121 | }
122 |
123 | if (config.build.bundleAnalyzerReport) {
124 | const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin
125 | webpackConfig.plugins.push(new BundleAnalyzerPlugin())
126 | }
127 |
128 | module.exports = webpackConfig
129 |
--------------------------------------------------------------------------------
/build/webpack.test.conf.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 | // This is the webpack config used for unit tests.
3 |
4 | const utils = require('./utils')
5 | const webpack = require('webpack')
6 | const merge = require('webpack-merge')
7 | const baseWebpackConfig = require('./webpack.base.conf')
8 |
9 | const webpackConfig = merge(baseWebpackConfig, {
10 | // use inline sourcemap for karma-sourcemap-loader
11 | module: {
12 | rules: utils.styleLoaders()
13 | },
14 | devtool: '#inline-source-map',
15 | resolveLoader: {
16 | alias: {
17 | // necessary to to make lang="scss" work in test when using vue-loader's ?inject option
18 | // see discussion at https://github.com/vuejs/vue-loader/issues/724
19 | 'scss-loader': 'sass-loader'
20 | }
21 | },
22 | plugins: [
23 | new webpack.DefinePlugin({
24 | 'process.env': require('../config/test.env')
25 | })
26 | ]
27 | })
28 |
29 | // no need for app entry during tests
30 | delete webpackConfig.entry
31 |
32 | module.exports = webpackConfig
33 |
--------------------------------------------------------------------------------
/config/dev.env.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 | const merge = require('webpack-merge')
3 | const prodEnv = require('./prod.env')
4 |
5 | module.exports = merge(prodEnv, {
6 | NODE_ENV: '"development"'
7 | })
8 |
--------------------------------------------------------------------------------
/config/index.js:
--------------------------------------------------------------------------------
1 |
2 | 'use strict'
3 | // Template version: 1.1.3
4 | // see http://vuejs-templates.github.io/webpack for documentation.
5 |
6 | const path = require('path')
7 |
8 | module.exports = {
9 | build: {
10 | env: require('./prod.env'),
11 | index: path.resolve(__dirname, '../dist/index.html'),
12 | assetsRoot: path.resolve(__dirname, '../dist'),
13 | assetsSubDirectory: 'static',
14 | assetsPublicPath: '/vue-boilerplate/',
15 | productionSourceMap: true,
16 | // Gzip off by default as many popular static hosts such as
17 | // Surge or Netlify already gzip all static assets for you.
18 | // Before setting to `true`, make sure to:
19 | // npm install --save-dev compression-webpack-plugin
20 | productionGzip: false,
21 | productionGzipExtensions: ['js', 'css'],
22 | // Run the build command with an extra argument to
23 | // View the bundle analyzer report after build finishes:
24 | // `npm run build --report`
25 | // Set to `true` or `false` to always turn it on or off
26 | bundleAnalyzerReport: process.env.npm_config_report
27 | },
28 | dev: {
29 | env: require('./dev.env'),
30 | port: process.env.PORT || 8080,
31 | autoOpenBrowser: true,
32 | assetsSubDirectory: 'static',
33 | assetsPublicPath: '/',
34 | proxyTable: {},
35 | // CSS Sourcemaps off by default because relative paths are "buggy"
36 | // with this option, according to the CSS-Loader README
37 | // (https://github.com/webpack/css-loader#sourcemaps)
38 | // In our experience, they generally work as expected,
39 | // just be aware of this issue when enabling this option.
40 | cssSourceMap: false
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/config/prod.env.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 | module.exports = {
3 | NODE_ENV: '"production"',
4 | API_ROOT: '"/api"'
5 | }
6 |
--------------------------------------------------------------------------------
/config/test.env.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 | const merge = require('webpack-merge')
3 | const devEnv = require('./dev.env')
4 |
5 | module.exports = merge(devEnv, {
6 | NODE_ENV: '"testing"'
7 | })
8 |
--------------------------------------------------------------------------------
/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | vue-boilerplate
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "vue-boilerplate",
3 | "version": "1.1.2",
4 | "description": "Vue 2.0 boilerplate includes vuex vue-router vue-resource",
5 | "author": "Miller Ren ",
6 | "private": true,
7 | "scripts": {
8 | "dev": "node build/dev-server.js",
9 | "build": "node build/build.js",
10 | "deploy": "npm run build && npm run gh-pages",
11 | "gh-pages": "gh-pages -d dist --remote origin",
12 | "unit": "karma start test/unit/karma.conf.js --single-run",
13 | "e2e": "node test/e2e/runner.js",
14 | "test": "npm run unit && npm run e2e",
15 | "lint": "eslint --ext .js,.vue src test/unit/specs test/e2e/specs",
16 | "preversion": "npm run build",
17 | "postversion": "git push && git push --tags && npm run gh-pages"
18 | },
19 | "dependencies": {
20 | "bootstrap": "^3.3.7",
21 | "nprogress": "^0.2.0",
22 | "vee-validate": "^2.0.0-rc.19",
23 | "vue": "^2.5.2",
24 | "vue-clickaway": "^2.1.0",
25 | "vue-resource": "^1.3.4",
26 | "vue-router": "^2.8.1",
27 | "vuelidate": "^0.6.1",
28 | "vuex": "^2.5.0",
29 | "vuex-router-sync": "^3.0.0"
30 | },
31 | "devDependencies": {
32 | "autoprefixer": "^7.1.2",
33 | "babel-core": "^6.22.1",
34 | "babel-eslint": "^7.1.1",
35 | "babel-loader": "^7.1.1",
36 | "babel-plugin-istanbul": "^4.1.1",
37 | "babel-plugin-transform-runtime": "^6.22.0",
38 | "babel-preset-env": "^1.3.2",
39 | "babel-preset-stage-2": "^6.22.0",
40 | "babel-register": "^6.22.0",
41 | "chai": "^4.1.2",
42 | "chalk": "^2.0.1",
43 | "chromedriver": "^2.27.2",
44 | "connect-history-api-fallback": "^1.3.0",
45 | "copy-webpack-plugin": "^4.0.1",
46 | "cross-env": "^5.0.1",
47 | "cross-spawn": "^5.0.1",
48 | "css-loader": "^0.28.0",
49 | "eslint": "^4.19.1",
50 | "eslint-config-standard": "^10.2.1",
51 | "eslint-friendly-formatter": "^3.0.0",
52 | "eslint-loader": "^1.7.1",
53 | "eslint-plugin-html": "^3.0.0",
54 | "eslint-plugin-import": "^2.7.0",
55 | "eslint-plugin-node": "^5.2.0",
56 | "eslint-plugin-promise": "^3.4.0",
57 | "eslint-plugin-standard": "^3.0.1",
58 | "eventsource-polyfill": "^0.9.6",
59 | "express": "^4.14.1",
60 | "extract-text-webpack-plugin": "^3.0.0",
61 | "file-loader": "^1.1.4",
62 | "friendly-errors-webpack-plugin": "^1.6.1",
63 | "gh-pages": "^1.0.0",
64 | "html-webpack-plugin": "^2.30.1",
65 | "http-proxy-middleware": "^0.17.3",
66 | "inject-loader": "^3.0.0",
67 | "karma": "^1.4.1",
68 | "karma-coverage": "^1.1.1",
69 | "karma-mocha": "^1.3.0",
70 | "karma-phantomjs-launcher": "^1.0.2",
71 | "karma-phantomjs-shim": "^1.4.0",
72 | "karma-sinon-chai": "^1.3.1",
73 | "karma-sourcemap-loader": "^0.3.7",
74 | "karma-spec-reporter": "0.0.31",
75 | "karma-webpack": "^2.0.2",
76 | "less": "^3.0.0-alpha.3",
77 | "less-loader": "^4.0.5",
78 | "mocha": "^3.2.0",
79 | "nightwatch": "^0.9.12",
80 | "opn": "^5.1.0",
81 | "optimize-css-assets-webpack-plugin": "^3.2.0",
82 | "ora": "^1.2.0",
83 | "phantomjs-prebuilt": "^2.1.14",
84 | "portfinder": "^1.0.13",
85 | "rimraf": "^2.6.0",
86 | "selenium-server": "^3.0.1",
87 | "semver": "^5.3.0",
88 | "shelljs": "^0.7.6",
89 | "sinon": "^4.0.0",
90 | "sinon-chai": "^2.8.0",
91 | "url-loader": "^0.5.8",
92 | "vue-loader": "^13.3.0",
93 | "vue-style-loader": "^3.0.1",
94 | "vue-template-compiler": "^2.5.2",
95 | "webpack": "^3.6.0",
96 | "webpack-bundle-analyzer": "^2.9.0",
97 | "webpack-dev-middleware": "^1.12.0",
98 | "webpack-hot-middleware": "^2.18.2",
99 | "webpack-merge": "^4.1.0"
100 | },
101 | "engines": {
102 | "node": ">= 4.0.0",
103 | "npm": ">= 3.0.0"
104 | },
105 | "browserslist": [
106 | "> 1%",
107 | "last 2 versions",
108 | "not ie <= 8"
109 | ]
110 | }
111 |
--------------------------------------------------------------------------------
/src/App.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
16 |
17 |
41 |
--------------------------------------------------------------------------------
/src/api/index.js:
--------------------------------------------------------------------------------
1 | import Vue from 'vue'
2 | import VueResource from 'vue-resource'
3 | import NProgress from 'nprogress'
4 | import 'nprogress/nprogress.css'
5 |
6 | const API_ROOT = process.env.API_ROOT
7 |
8 | Vue.use(VueResource)
9 |
10 | Vue.http.options.crossOrigin = true
11 | Vue.http.options.xhr = {withCredentials: true}
12 | Vue.http.options.root = API_ROOT
13 | // Vue.http.options.emulateJSON = true
14 |
15 | Vue.http.options.progress = function (event) {
16 | if (event.lengthComputable) {
17 | NProgress.set(event.loaded / event.total)
18 | }
19 | }
20 |
21 | Vue.http.interceptors.push((request, next) => {
22 | NProgress.start()
23 | request.headers.set('Authorization', 'Bearer ' + localStorage.getItem('token'))
24 | next((response) => {
25 | NProgress.done()
26 | if (response.status >= 400) {
27 | Vue.toastr({
28 | message: response.statusText,
29 | type: 'danger'
30 | })
31 | }
32 | return response
33 | })
34 | })
35 |
36 | export const Account = Vue.resource('/users{/id}')
37 |
38 | export const Auth = Vue.resource('/auth/local')
39 |
--------------------------------------------------------------------------------
/src/assets/awesome-vue.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MillerRen/vue-boilerplate/6b12cf3d13f84db9902057ff908cd869a1f5e0cb/src/assets/awesome-vue.png
--------------------------------------------------------------------------------
/src/assets/github.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/src/assets/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MillerRen/vue-boilerplate/6b12cf3d13f84db9902057ff908cd869a1f5e0cb/src/assets/logo.png
--------------------------------------------------------------------------------
/src/components/FormGroup.vue:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
31 |
--------------------------------------------------------------------------------
/src/components/Hello.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
{{ msg }}
4 |
Essential Links
5 |
13 |
Ecosystem
14 |
20 |
21 |
22 |
23 |
33 |
34 |
35 |
54 |
--------------------------------------------------------------------------------
/src/components/LoginForm.vue:
--------------------------------------------------------------------------------
1 |
2 |
13 |
14 |
15 |
60 |
61 |
63 |
--------------------------------------------------------------------------------
/src/components/Modal.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
8 |
9 |
10 |
11 | {{message}}
12 |
13 |
14 |
15 |
16 |
19 |
20 |
21 |
22 |
23 |
24 |
118 |
119 |
--------------------------------------------------------------------------------
/src/components/Navbar.vue:
--------------------------------------------------------------------------------
1 |
2 |
39 |
40 |
41 |
79 |
80 |
90 |
--------------------------------------------------------------------------------
/src/components/Toastr.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
7 | {{message}}
8 |
9 |
10 |
11 |
12 |
41 |
42 |
--------------------------------------------------------------------------------
/src/components/index.js:
--------------------------------------------------------------------------------
1 | import Vue from 'vue'
2 |
3 | Vue.component('form-group', () => import('./FormGroup'))
4 | Vue.component('login-form', () => import('./LoginForm'))
5 |
--------------------------------------------------------------------------------
/src/directives/dropdown.js:
--------------------------------------------------------------------------------
1 |
2 | const DROPDOWN_HANDLER = '__dropdown_handler'
3 | const DOCUMENT_DROPDOWN_HANDLER = '__document_dropdown_handler'
4 |
5 | export default {
6 | bind (el, binding, vnode) {
7 | el[DROPDOWN_HANDLER] = (e) => {
8 | e.stopPropagation()
9 | el.classList.toggle('open')
10 | }
11 | el[DOCUMENT_DROPDOWN_HANDLER] = (e) => {
12 | el.classList.remove('open')
13 | }
14 | el.addEventListener('click', el[DROPDOWN_HANDLER])
15 | document.addEventListener('click', el[DOCUMENT_DROPDOWN_HANDLER])
16 | },
17 | unbind (el, binding, vnode) {
18 | el.removeEventListener('click', el[DROPDOWN_HANDLER])
19 | document.removeEventListener('click', el[DOCUMENT_DROPDOWN_HANDLER])
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/src/directives/index.js:
--------------------------------------------------------------------------------
1 | import Vue from 'vue'
2 | import {directive as Clickaway} from 'vue-clickaway'
3 |
4 | Vue.directive('clickaway', Clickaway)
5 |
--------------------------------------------------------------------------------
/src/filters/index.js:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MillerRen/vue-boilerplate/6b12cf3d13f84db9902057ff908cd869a1f5e0cb/src/filters/index.js
--------------------------------------------------------------------------------
/src/locales/index.js:
--------------------------------------------------------------------------------
1 | import Vue from 'vue'
2 | import VueI18n from 'vue-i18n'
3 |
4 | Vue.use(VueI18n)
5 |
6 | const i18n = new VueI18n({
7 | locale: 'zh_CN',
8 | fallbackLocale: 'en'
9 | })
10 |
11 | export default i18n
12 |
--------------------------------------------------------------------------------
/src/main.js:
--------------------------------------------------------------------------------
1 | // The Vue build version to load with the `import` command
2 | // (runtime-only or standalone) has been set in webpack.base.conf with an alias.
3 | import Vue from 'vue'
4 | import store from '@/store'
5 | import router from '@/router'
6 | import VuexRouterSync from 'vuex-router-sync'
7 | import App from './App'
8 |
9 | import '@/plugins'
10 | import '@/validators'
11 | import '@/directives'
12 | import '@/filters'
13 | import '@/mixins'
14 | import '@/locales'
15 | import '@/components'
16 |
17 | Vue.config.productionTip = false
18 |
19 | VuexRouterSync.sync(store, router)
20 |
21 | /* eslint-disable no-new */
22 | new Vue({
23 | el: 'app',
24 | router,
25 | store,
26 | ...App
27 | })
28 |
--------------------------------------------------------------------------------
/src/mixins/index.js:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/src/plugins/component.js:
--------------------------------------------------------------------------------
1 | // register or get a local component
2 | import Vue from 'vue'
3 |
4 | export default {
5 | install () {
6 | Vue.prototype.$component = function (name, component) {
7 | if (component) {
8 | this.$options.components[name] = component
9 | }
10 | return this.$options.components[name]
11 | }
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/src/plugins/index.js:
--------------------------------------------------------------------------------
1 | import Vue from 'vue'
2 | import VueModal from './modal'
3 | import VueComponent from './component'
4 | import VueToastr from './toastr'
5 |
6 | Vue.use(VueComponent)
7 |
8 | Vue.use(VueModal)
9 |
10 | Vue.use(VueToastr)
11 |
--------------------------------------------------------------------------------
/src/plugins/modal.js:
--------------------------------------------------------------------------------
1 | import Vue from 'vue'
2 | import Modal from '@/components/Modal'
3 |
4 | const ModalConstructor = Vue.extend(Modal)
5 |
6 | function modal (opts) {
7 | var instance = new ModalConstructor({
8 | propsData: opts
9 | })
10 | if (opts.component) {
11 | instance.$options.components[opts.name] = opts.component
12 | }
13 | instance.$mount()
14 | document.body.appendChild(instance.$el)
15 | return instance
16 | }
17 |
18 | function install (opts) {
19 | Vue.prototype.$modal = modal
20 | Vue.modal = modal
21 | }
22 |
23 | export default {
24 | install
25 | }
26 |
--------------------------------------------------------------------------------
/src/plugins/toastr.js:
--------------------------------------------------------------------------------
1 | import Vue from 'vue'
2 | import Toastr from '@/components/Toastr'
3 |
4 | const Ctor = Vue.extend(Toastr)
5 |
6 | function toastr (opts) {
7 | var instance = new Ctor({
8 | propsData: opts
9 | }).$mount()
10 | document.body.appendChild(instance.$el)
11 | return instance
12 | }
13 |
14 | export default {
15 | install () {
16 | Vue.toastr = toastr
17 | Vue.prototype.$toastr = toastr
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/src/router/index.js:
--------------------------------------------------------------------------------
1 | import Vue from 'vue'
2 | import VueRouter from 'vue-router'
3 | import NProgress from 'nprogress'
4 | import 'nprogress/nprogress.css'
5 | import routes from './routes'
6 |
7 | Vue.use(VueRouter)
8 |
9 | const router = new VueRouter({
10 | linkActiveClass: 'active',
11 | mode: 'history',
12 | base: '/vue-boilerplate/',
13 | routes: routes,
14 | scrollBehavior (to, from, savedPosition) {
15 | return { x: 0, y: 0 }
16 | }
17 | })
18 |
19 | router.beforeEach((to, from, next) => {
20 | NProgress.start()
21 | next()
22 | })
23 |
24 | router.afterEach(() => {
25 | NProgress.done()
26 | })
27 |
28 | router.beforeEach((to, from, next) => {
29 | if (!to.meta.requiresAuth) return next()
30 | if (!localStorage.token) {
31 | return next({
32 | path: '/auth/local',
33 | query: { redirect: to.fullPath }
34 | })
35 | }
36 | next()
37 | })
38 |
39 | export default router
40 |
--------------------------------------------------------------------------------
/src/router/routes.js:
--------------------------------------------------------------------------------
1 | import Empty from '@/views/Empty'
2 | import Navbar from '@/components/Navbar'
3 |
4 | export default [
5 | {
6 | path: '/',
7 | components: {
8 | header: Navbar,
9 | default: () => import('@/views/Home')
10 | }
11 | },
12 | {
13 | path: '/auth/local',
14 | component: () => import('@/views/Auth/Login')
15 | },
16 | {
17 | path: '*',
18 | component: Empty
19 | }
20 | ]
21 |
--------------------------------------------------------------------------------
/src/router/transition.less:
--------------------------------------------------------------------------------
1 | .router-view {
2 | transition: all .5s ease;
3 | min-height: 100vh;
4 | }
5 |
6 | .router-enter, .router-leave {
7 | opacity: 0;
8 | transform: translate3d(20px, 0, 0);
9 | }
--------------------------------------------------------------------------------
/src/store/index.js:
--------------------------------------------------------------------------------
1 | import Vue from 'vue'
2 | import Vuex from 'vuex'
3 | import createLogger from 'vuex/dist/logger'
4 | import account from './modules/account'
5 | import auth from './modules/auth'
6 |
7 | Vue.use(Vuex)
8 |
9 | const debug = process.env.NODE_ENV !== 'production'
10 |
11 | const store = new Vuex.Store({
12 | modules: {
13 | account,
14 | auth
15 | },
16 | strict: false,
17 | plugins: debug ? [createLogger()] : []
18 | })
19 |
20 | export default store
21 |
--------------------------------------------------------------------------------
/src/store/modules/account.js:
--------------------------------------------------------------------------------
1 |
2 | const GET_ACCOUNT_SUCCESS = 'GET_ACCOUNT_SUCCESS'
3 | const GET_ACCOUNT_FAIL = 'GET_ACCOUNT_FAIL'
4 |
5 | const state = {
6 | account: null
7 | }
8 |
9 | const getters = {
10 | account (state) {
11 | return state.account
12 | }
13 | }
14 |
15 | const mutations = {
16 | [GET_ACCOUNT_SUCCESS] (state, account) {
17 | state.account = account
18 | },
19 | [GET_ACCOUNT_FAIL] (state, err) {
20 | state.account = {}
21 | }
22 | }
23 |
24 | const actions = {
25 | }
26 |
27 | export default {
28 | state,
29 | getters,
30 | mutations,
31 | actions
32 | }
33 |
--------------------------------------------------------------------------------
/src/store/modules/auth.js:
--------------------------------------------------------------------------------
1 | import * as API from '@/api'
2 |
3 | const AUTH_LOGIN_SUCCESS = 'AUTH_LOGIN_SUCCESS'
4 | const AUTH_LOGIN_FAIL = 'AUTH_LOGIN_FAIL'
5 | const AUTH_LOGOUT = 'AUTH_LOGOUT'
6 |
7 | const state = {
8 | token: localStorage.getItem('token') || ''
9 | }
10 |
11 | const getters = {}
12 |
13 | const mutations = {
14 | [AUTH_LOGIN_SUCCESS] (state, data) {
15 | state.token = data.token
16 | localStorage.setItem('token', data.token)
17 | },
18 | [AUTH_LOGIN_FAIL] (state, err) {
19 | state.token = ''
20 | localStorage.setItem('token', '')
21 | },
22 | [AUTH_LOGOUT] (state, err) {
23 | state.token = ''
24 | localStorage.setItem('token', '')
25 | }
26 | }
27 |
28 | const actions = {
29 | login ({commit}, data) {
30 | return API.Auth.save(data)
31 | .then((res) => {
32 | commit(AUTH_LOGIN_SUCCESS, res.body)
33 | })
34 | .catch((res) => {
35 | commit(AUTH_LOGIN_FAIL)
36 | return Promise.reject(res)
37 | })
38 | },
39 | logout ({commit}) {
40 | commit(AUTH_LOGOUT)
41 | }
42 | }
43 |
44 | export default {
45 | state,
46 | getters,
47 | mutations,
48 | actions
49 | }
50 |
--------------------------------------------------------------------------------
/src/theme/default.less:
--------------------------------------------------------------------------------
1 | /*!
2 | * Bootstrap v3.3.7 (http://getbootstrap.com)
3 | * Copyright 2011-2016 Twitter, Inc.
4 | * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
5 | */
6 |
7 | //
8 | // Load core variables and mixins
9 | // --------------------------------------------------
10 |
11 | @import "~bootstrap/less/variables.less";
12 | @import "~bootstrap/less/mixins.less";
13 |
14 |
15 | //
16 | // Buttons
17 | // --------------------------------------------------
18 |
19 | // Common styles
20 | .btn-default,
21 | .btn-primary,
22 | .btn-success,
23 | .btn-info,
24 | .btn-warning,
25 | .btn-danger {
26 | text-shadow: 0 -1px 0 rgba(0,0,0,.2);
27 | @shadow: inset 0 1px 0 rgba(255,255,255,.15), 0 1px 1px rgba(0,0,0,.075);
28 | .box-shadow(@shadow);
29 |
30 | // Reset the shadow
31 | &:active,
32 | &.active {
33 | .box-shadow(inset 0 3px 5px rgba(0,0,0,.125));
34 | }
35 |
36 | &.disabled,
37 | &[disabled],
38 | fieldset[disabled] & {
39 | .box-shadow(none);
40 | }
41 |
42 | .badge {
43 | text-shadow: none;
44 | }
45 | }
46 |
47 | // Mixin for generating new styles
48 | .btn-styles(@btn-color: #555) {
49 | #gradient > .vertical(@start-color: @btn-color; @end-color: darken(@btn-color, 12%));
50 | .reset-filter(); // Disable gradients for IE9 because filter bleeds through rounded corners; see https://github.com/twbs/bootstrap/issues/10620
51 | background-repeat: repeat-x;
52 | border-color: darken(@btn-color, 14%);
53 |
54 | &:hover,
55 | &:focus {
56 | background-color: darken(@btn-color, 12%);
57 | background-position: 0 -15px;
58 | }
59 |
60 | &:active,
61 | &.active {
62 | background-color: darken(@btn-color, 12%);
63 | border-color: darken(@btn-color, 14%);
64 | }
65 |
66 | &.disabled,
67 | &[disabled],
68 | fieldset[disabled] & {
69 | &,
70 | &:hover,
71 | &:focus,
72 | &.focus,
73 | &:active,
74 | &.active {
75 | background-color: darken(@btn-color, 12%);
76 | background-image: none;
77 | }
78 | }
79 | }
80 |
81 | // Common styles
82 | .btn {
83 | // Remove the gradient for the pressed/active state
84 | &:active,
85 | &.active {
86 | background-image: none;
87 | }
88 | }
89 |
90 | // Apply the mixin to the buttons
91 | .btn-default { .btn-styles(@btn-default-bg); text-shadow: 0 1px 0 #fff; border-color: #ccc; }
92 | .btn-primary { .btn-styles(@btn-primary-bg); }
93 | .btn-success { .btn-styles(@btn-success-bg); }
94 | .btn-info { .btn-styles(@btn-info-bg); }
95 | .btn-warning { .btn-styles(@btn-warning-bg); }
96 | .btn-danger { .btn-styles(@btn-danger-bg); }
97 |
98 |
99 | //
100 | // Images
101 | // --------------------------------------------------
102 |
103 | .thumbnail,
104 | .img-thumbnail {
105 | .box-shadow(0 1px 2px rgba(0,0,0,.075));
106 | }
107 |
108 |
109 | //
110 | // Dropdowns
111 | // --------------------------------------------------
112 |
113 | .dropdown-menu > li > a:hover,
114 | .dropdown-menu > li > a:focus {
115 | #gradient > .vertical(@start-color: @dropdown-link-hover-bg; @end-color: darken(@dropdown-link-hover-bg, 5%));
116 | background-color: darken(@dropdown-link-hover-bg, 5%);
117 | }
118 | .dropdown-menu > .active > a,
119 | .dropdown-menu > .active > a:hover,
120 | .dropdown-menu > .active > a:focus {
121 | #gradient > .vertical(@start-color: @dropdown-link-active-bg; @end-color: darken(@dropdown-link-active-bg, 5%));
122 | background-color: darken(@dropdown-link-active-bg, 5%);
123 | }
124 |
125 |
126 | //
127 | // Navbar
128 | // --------------------------------------------------
129 |
130 | // Default navbar
131 | .navbar-default {
132 | #gradient > .vertical(@start-color: lighten(@navbar-default-bg, 10%); @end-color: @navbar-default-bg);
133 | .reset-filter(); // Remove gradient in IE<10 to fix bug where dropdowns don't get triggered
134 | border-radius: @navbar-border-radius;
135 | @shadow: inset 0 1px 0 rgba(255,255,255,.15), 0 1px 5px rgba(0,0,0,.075);
136 | .box-shadow(@shadow);
137 |
138 | .navbar-nav > .open > a,
139 | .navbar-nav > .active > a {
140 | #gradient > .vertical(@start-color: darken(@navbar-default-link-active-bg, 5%); @end-color: darken(@navbar-default-link-active-bg, 2%));
141 | .box-shadow(inset 0 3px 9px rgba(0,0,0,.075));
142 | }
143 | }
144 | .navbar-brand,
145 | .navbar-nav > li > a {
146 | text-shadow: 0 1px 0 rgba(255,255,255,.25);
147 | }
148 |
149 | // Inverted navbar
150 | .navbar-inverse {
151 | #gradient > .vertical(@start-color: lighten(@navbar-inverse-bg, 10%); @end-color: @navbar-inverse-bg);
152 | .reset-filter(); // Remove gradient in IE<10 to fix bug where dropdowns don't get triggered; see https://github.com/twbs/bootstrap/issues/10257
153 | border-radius: @navbar-border-radius;
154 | .navbar-nav > .open > a,
155 | .navbar-nav > .active > a {
156 | #gradient > .vertical(@start-color: @navbar-inverse-link-active-bg; @end-color: lighten(@navbar-inverse-link-active-bg, 2.5%));
157 | .box-shadow(inset 0 3px 9px rgba(0,0,0,.25));
158 | }
159 |
160 | .navbar-brand,
161 | .navbar-nav > li > a {
162 | text-shadow: 0 -1px 0 rgba(0,0,0,.25);
163 | }
164 | }
165 |
166 | // Undo rounded corners in static and fixed navbars
167 | .navbar-static-top,
168 | .navbar-fixed-top,
169 | .navbar-fixed-bottom {
170 | border-radius: 0;
171 | }
172 |
173 | // Fix active state of dropdown items in collapsed mode
174 | @media (max-width: @grid-float-breakpoint-max) {
175 | .navbar .navbar-nav .open .dropdown-menu > .active > a {
176 | &,
177 | &:hover,
178 | &:focus {
179 | color: #fff;
180 | #gradient > .vertical(@start-color: @dropdown-link-active-bg; @end-color: darken(@dropdown-link-active-bg, 5%));
181 | }
182 | }
183 | }
184 |
185 |
186 | //
187 | // Alerts
188 | // --------------------------------------------------
189 |
190 | // Common styles
191 | .alert {
192 | text-shadow: 0 1px 0 rgba(255,255,255,.2);
193 | @shadow: inset 0 1px 0 rgba(255,255,255,.25), 0 1px 2px rgba(0,0,0,.05);
194 | .box-shadow(@shadow);
195 | }
196 |
197 | // Mixin for generating new styles
198 | .alert-styles(@color) {
199 | #gradient > .vertical(@start-color: @color; @end-color: darken(@color, 7.5%));
200 | border-color: darken(@color, 15%);
201 | }
202 |
203 | // Apply the mixin to the alerts
204 | .alert-success { .alert-styles(@alert-success-bg); }
205 | .alert-info { .alert-styles(@alert-info-bg); }
206 | .alert-warning { .alert-styles(@alert-warning-bg); }
207 | .alert-danger { .alert-styles(@alert-danger-bg); }
208 |
209 |
210 | //
211 | // Progress bars
212 | // --------------------------------------------------
213 |
214 | // Give the progress background some depth
215 | .progress {
216 | #gradient > .vertical(@start-color: darken(@progress-bg, 4%); @end-color: @progress-bg)
217 | }
218 |
219 | // Mixin for generating new styles
220 | .progress-bar-styles(@color) {
221 | #gradient > .vertical(@start-color: @color; @end-color: darken(@color, 10%));
222 | }
223 |
224 | // Apply the mixin to the progress bars
225 | .progress-bar { .progress-bar-styles(@progress-bar-bg); }
226 | .progress-bar-success { .progress-bar-styles(@progress-bar-success-bg); }
227 | .progress-bar-info { .progress-bar-styles(@progress-bar-info-bg); }
228 | .progress-bar-warning { .progress-bar-styles(@progress-bar-warning-bg); }
229 | .progress-bar-danger { .progress-bar-styles(@progress-bar-danger-bg); }
230 |
231 | // Reset the striped class because our mixins don't do multiple gradients and
232 | // the above custom styles override the new `.progress-bar-striped` in v3.2.0.
233 | .progress-bar-striped {
234 | #gradient > .striped();
235 | }
236 |
237 |
238 | //
239 | // List groups
240 | // --------------------------------------------------
241 |
242 | .list-group {
243 | border-radius: @border-radius-base;
244 | .box-shadow(0 1px 2px rgba(0,0,0,.075));
245 | }
246 | .list-group-item.active,
247 | .list-group-item.active:hover,
248 | .list-group-item.active:focus {
249 | text-shadow: 0 -1px 0 darken(@list-group-active-bg, 10%);
250 | #gradient > .vertical(@start-color: @list-group-active-bg; @end-color: darken(@list-group-active-bg, 7.5%));
251 | border-color: darken(@list-group-active-border, 7.5%);
252 |
253 | .badge {
254 | text-shadow: none;
255 | }
256 | }
257 |
258 |
259 | //
260 | // Panels
261 | // --------------------------------------------------
262 |
263 | // Common styles
264 | .panel {
265 | .box-shadow(0 1px 2px rgba(0,0,0,.05));
266 | }
267 |
268 | // Mixin for generating new styles
269 | .panel-heading-styles(@color) {
270 | #gradient > .vertical(@start-color: @color; @end-color: darken(@color, 5%));
271 | }
272 |
273 | // Apply the mixin to the panel headings only
274 | .panel-default > .panel-heading { .panel-heading-styles(@panel-default-heading-bg); }
275 | .panel-primary > .panel-heading { .panel-heading-styles(@panel-primary-heading-bg); }
276 | .panel-success > .panel-heading { .panel-heading-styles(@panel-success-heading-bg); }
277 | .panel-info > .panel-heading { .panel-heading-styles(@panel-info-heading-bg); }
278 | .panel-warning > .panel-heading { .panel-heading-styles(@panel-warning-heading-bg); }
279 | .panel-danger > .panel-heading { .panel-heading-styles(@panel-danger-heading-bg); }
280 |
281 |
282 | //
283 | // Wells
284 | // --------------------------------------------------
285 |
286 | .well {
287 | #gradient > .vertical(@start-color: darken(@well-bg, 5%); @end-color: @well-bg);
288 | border-color: darken(@well-bg, 10%);
289 | @shadow: inset 0 1px 3px rgba(0,0,0,.05), 0 1px 0 rgba(255,255,255,.1);
290 | .box-shadow(@shadow);
291 | }
292 |
--------------------------------------------------------------------------------
/src/utils/index.js:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MillerRen/vue-boilerplate/6b12cf3d13f84db9902057ff908cd869a1f5e0cb/src/utils/index.js
--------------------------------------------------------------------------------
/src/validators/index.js:
--------------------------------------------------------------------------------
1 | import Vue from 'vue'
2 | import Vuelidate from 'vuelidate'
3 |
4 | Vue.use(Vuelidate)
5 |
--------------------------------------------------------------------------------
/src/views/Account/Profile.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
![]()
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
30 |
31 |
32 |
--------------------------------------------------------------------------------
/src/views/Auth/Login.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
Login
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
39 |
--------------------------------------------------------------------------------
/src/views/Auth/Register.vue:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MillerRen/vue-boilerplate/6b12cf3d13f84db9902057ff908cd869a1f5e0cb/src/views/Auth/Register.vue
--------------------------------------------------------------------------------
/src/views/Empty.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 | page not found back home
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/src/views/Home/Jumbotron.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |

5 |
6 |
7 |
8 |
9 |
10 |
20 |
--------------------------------------------------------------------------------
/src/views/Home/index.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
16 |
17 |
23 |
--------------------------------------------------------------------------------
/static/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MillerRen/vue-boilerplate/6b12cf3d13f84db9902057ff908cd869a1f5e0cb/static/.gitkeep
--------------------------------------------------------------------------------
/static/loading.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/test/e2e/custom-assertions/elementCount.js:
--------------------------------------------------------------------------------
1 | // A custom Nightwatch assertion.
2 | // the name of the method is the filename.
3 | // can be used in tests like this:
4 | //
5 | // browser.assert.elementCount(selector, count)
6 | //
7 | // for how to write custom assertions see
8 | // http://nightwatchjs.org/guide#writing-custom-assertions
9 | exports.assertion = function (selector, count) {
10 | this.message = 'Testing if element <' + selector + '> has count: ' + count
11 | this.expected = count
12 | this.pass = function (val) {
13 | return val === this.expected
14 | }
15 | this.value = function (res) {
16 | return res.value
17 | }
18 | this.command = function (cb) {
19 | var self = this
20 | return this.api.execute(function (selector) {
21 | return document.querySelectorAll(selector).length
22 | }, [selector], function (res) {
23 | cb.call(self, res)
24 | })
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/test/e2e/nightwatch.conf.js:
--------------------------------------------------------------------------------
1 | require('babel-register')
2 | var config = require('../../config')
3 |
4 | // http://nightwatchjs.org/getingstarted#settings-file
5 | module.exports = {
6 | src_folders: ['test/e2e/specs'],
7 | output_folder: 'test/e2e/reports',
8 | custom_assertions_path: ['test/e2e/custom-assertions'],
9 |
10 | selenium: {
11 | start_process: true,
12 | server_path: require('selenium-server').path,
13 | host: '127.0.0.1',
14 | port: 4444,
15 | cli_args: {
16 | 'webdriver.chrome.driver': require('chromedriver').path
17 | }
18 | },
19 |
20 | test_settings: {
21 | default: {
22 | selenium_port: 4444,
23 | selenium_host: 'localhost',
24 | silent: true,
25 | globals: {
26 | devServerURL: 'http://localhost:' + (process.env.PORT || config.dev.port)
27 | }
28 | },
29 |
30 | chrome: {
31 | desiredCapabilities: {
32 | browserName: 'chrome',
33 | javascriptEnabled: true,
34 | acceptSslCerts: true
35 | }
36 | },
37 |
38 | firefox: {
39 | desiredCapabilities: {
40 | browserName: 'firefox',
41 | javascriptEnabled: true,
42 | acceptSslCerts: true
43 | }
44 | }
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/test/e2e/runner.js:
--------------------------------------------------------------------------------
1 | // 1. start the dev server using production config
2 | process.env.NODE_ENV = 'testing'
3 | var server = require('../../build/dev-server.js')
4 |
5 | server.ready.then(() => {
6 | // 2. run the nightwatch test suite against it
7 | // to run in additional browsers:
8 | // 1. add an entry in test/e2e/nightwatch.conf.json under "test_settings"
9 | // 2. add it to the --env flag below
10 | // or override the environment flag, for example: `npm run e2e -- --env chrome,firefox`
11 | // For more information on Nightwatch's config file, see
12 | // http://nightwatchjs.org/guide#settings-file
13 | var opts = process.argv.slice(2)
14 | if (opts.indexOf('--config') === -1) {
15 | opts = opts.concat(['--config', 'test/e2e/nightwatch.conf.js'])
16 | }
17 | if (opts.indexOf('--env') === -1) {
18 | opts = opts.concat(['--env', 'chrome'])
19 | }
20 |
21 | var spawn = require('cross-spawn')
22 | var runner = spawn('./node_modules/.bin/nightwatch', opts, { stdio: 'inherit' })
23 |
24 | runner.on('exit', function (code) {
25 | server.close()
26 | process.exit(code)
27 | })
28 |
29 | runner.on('error', function (err) {
30 | server.close()
31 | throw err
32 | })
33 | })
34 |
--------------------------------------------------------------------------------
/test/e2e/specs/test.js:
--------------------------------------------------------------------------------
1 | // For authoring Nightwatch tests, see
2 | // http://nightwatchjs.org/guide#usage
3 |
4 | module.exports = {
5 | 'default e2e tests': function (browser) {
6 | // automatically uses dev Server port from /config.index.js
7 | // default: http://localhost:8080
8 | // see nightwatch.conf.js
9 | const devServer = browser.globals.devServerURL
10 |
11 | browser
12 | .url(devServer)
13 | .waitForElementVisible('#app', 5000)
14 | .assert.elementPresent('.hello')
15 | .assert.containsText('h1', 'Welcome to Your Vue.js App')
16 | .end()
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/test/unit/.eslintrc:
--------------------------------------------------------------------------------
1 | {
2 | "env": {
3 | "mocha": true
4 | },
5 | "globals": {
6 | "expect": true,
7 | "sinon": true
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/test/unit/index.js:
--------------------------------------------------------------------------------
1 | import Vue from 'vue'
2 | Vue.config.productionTip = false
3 |
4 | // Polyfill fn.bind() for PhantomJS
5 | /* eslint-disable no-extend-native */
6 | Function.prototype.bind = require('function-bind')
7 |
8 | // require all test files (files that ends with .spec.js)
9 | const testsContext = require.context('./specs', true, /\.spec$/)
10 | testsContext.keys().forEach(testsContext)
11 |
12 | // require all src files except main.js for coverage.
13 | // you can also change this to match only the subset of files that
14 | // you want coverage for.
15 | const srcContext = require.context('../../src', true, /^\.\/(?!main(\.js)?$)/)
16 | srcContext.keys().forEach(srcContext)
17 |
--------------------------------------------------------------------------------
/test/unit/karma.conf.js:
--------------------------------------------------------------------------------
1 | // This is a karma config file. For more details see
2 | // http://karma-runner.github.io/0.13/config/configuration-file.html
3 | // we are also using it with karma-webpack
4 | // https://github.com/webpack/karma-webpack
5 |
6 | var webpackConfig = require('../../build/webpack.test.conf')
7 |
8 | module.exports = function (config) {
9 | config.set({
10 | // to run in additional browsers:
11 | // 1. install corresponding karma launcher
12 | // http://karma-runner.github.io/0.13/config/browsers.html
13 | // 2. add it to the `browsers` array below.
14 | browsers: ['PhantomJS'],
15 | frameworks: ['mocha', 'sinon-chai'],
16 | reporters: ['spec', 'coverage'],
17 | files: ['../../node_modules/es6-promise/dist/es6-promise.auto.js', './index.js'],
18 | preprocessors: {
19 | './index.js': ['webpack', 'sourcemap']
20 | },
21 | webpack: webpackConfig,
22 | webpackMiddleware: {
23 | noInfo: true
24 | },
25 | coverageReporter: {
26 | dir: './coverage',
27 | reporters: [
28 | { type: 'lcov', subdir: '.' },
29 | { type: 'text-summary' }
30 | ]
31 | }
32 | })
33 | }
34 |
--------------------------------------------------------------------------------
/test/unit/specs/Hello.spec.js:
--------------------------------------------------------------------------------
1 | import Vue from 'vue'
2 | import Hello from '@/components/Hello'
3 |
4 | describe('Hello.vue', () => {
5 | it('should render correct contents', () => {
6 | const Constructor = Vue.extend(Hello)
7 | const vm = new Constructor().$mount()
8 | expect(vm.$el.querySelector('.hello h1').textContent)
9 | .to.equal('Welcome to Your Vue.js App')
10 | })
11 | })
12 |
--------------------------------------------------------------------------------