Skip to content

Commit fd9c3ef

Browse files
committed
Release 1.1.0 (Merge from develop)
2 parents 415caed + fa51a81 commit fd9c3ef

25 files changed

+191
-137
lines changed

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2013-present, Yuxi (Evan) You
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in
13+
all copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21+
THE SOFTWARE.

docs/backend.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ Let's take a look at the default `config/index.js`:
66

77
``` js
88
// config/index.js
9-
var path = require('path')
9+
'use strict'
10+
const path = require('path')
1011

1112
module.exports = {
1213
build: {

docs/linter.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Linter Configuration
22

3-
This boilerplate uses [ESLint](http://eslint.org/) as the linter, and uses the [Standard](https://github.com/feross/standard/blob/master/RULES.md) preset with some small customizations.
3+
This boilerplate uses [ESLint](https://eslint.org/) as the linter, and uses the [Standard](https://github.com/feross/standard/blob/master/RULES.md) preset with some small customizations.
44

55
If you are not happy with the default linting rules, you have several options:
66

@@ -13,4 +13,4 @@ If you are not happy with the default linting rules, you have several options:
1313

1414
2. Pick a different ESLint preset when generating the project, for example [eslint-config-airbnb](https://github.com/airbnb/javascript/tree/master/packages/eslint-config-airbnb).
1515

16-
3. Pick "none" for ESLint preset when generating the project and define your own rules. See [ESLint documentation](http://eslint.org/docs/rules/) for more details.
16+
3. Pick "none" for ESLint preset when generating the project and define your own rules. See [ESLint documentation](https://eslint.org/docs/rules/) for more details.

docs/prerender.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ npm install --save-dev prerender-spa-plugin
1414

1515
```js
1616
// This line should go at the top of the file where other 'imports' live in
17-
var PrerenderSpaPlugin = require('prerender-spa-plugin')
17+
const PrerenderSpaPlugin = require('prerender-spa-plugin')
1818
```
1919

2020
3. Configure it in the `plugins` array (also in **build/webpack.prod.conf.js**):

template/.eslintrc.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// http://eslint.org/docs/user-guide/configuring
1+
// https://eslint.org/docs/user-guide/configuring
22

33
module.exports = {
44
root: true,

template/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ selenium-debug.log
1414

1515
# Editor directories and files
1616
.idea
17+
.vscode
1718
*.suo
1819
*.ntvs*
1920
*.njsproj

template/build/build.js

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
1+
'use strict'
12
require('./check-versions')()
23

34
process.env.NODE_ENV = 'production'
45

5-
var ora = require('ora')
6-
var rm = require('rimraf')
7-
var path = require('path')
8-
var chalk = require('chalk')
9-
var webpack = require('webpack')
10-
var config = require('../config')
11-
var webpackConfig = require('./webpack.prod.conf')
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')
1213

13-
var spinner = ora('building for production...')
14+
const spinner = ora('building for production...')
1415
spinner.start()
1516

1617
rm(path.join(config.build.assetsRoot, config.build.assetsSubDirectory), err => {

template/build/check-versions.js

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
1-
var chalk = require('chalk')
2-
var semver = require('semver')
3-
var packageConfig = require('../package.json')
4-
var shell = require('shelljs')
1+
'use strict'
2+
const chalk = require('chalk')
3+
const semver = require('semver')
4+
const packageConfig = require('../package.json')
5+
const shell = require('shelljs')
56
function exec (cmd) {
67
return require('child_process').execSync(cmd).toString().trim()
78
}
89

9-
var versionRequirements = [
10+
const versionRequirements = [
1011
{
1112
name: 'node',
1213
currentVersion: semver.clean(process.version),
@@ -23,9 +24,9 @@ if (shell.which('npm')) {
2324
}
2425

2526
module.exports = function () {
26-
var warnings = []
27-
for (var i = 0; i < versionRequirements.length; i++) {
28-
var mod = versionRequirements[i]
27+
const warnings = []
28+
for (let i = 0; i < versionRequirements.length; i++) {
29+
const mod = versionRequirements[i]
2930
if (!semver.satisfies(mod.currentVersion, mod.versionRequirement)) {
3031
warnings.push(mod.name + ': ' +
3132
chalk.red(mod.currentVersion) + ' should be ' +
@@ -38,8 +39,8 @@ module.exports = function () {
3839
console.log('')
3940
console.log(chalk.yellow('To use this template, you must update following to modules:'))
4041
console.log()
41-
for (var i = 0; i < warnings.length; i++) {
42-
var warning = warnings[i]
42+
for (let i = 0; i < warnings.length; i++) {
43+
const warning = warnings[i]
4344
console.log(' ' + warning)
4445
}
4546
console.log()

template/build/dev-client.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/* eslint-disable */
2+
'use strict'
23
require('eventsource-polyfill')
3-
var hotClient = require('webpack-hot-middleware/client?noInfo=true&reload=true')
4+
const hotClient = require('webpack-hot-middleware/client?noInfo=true&reload=true')
45

56
hotClient.subscribe(function (event) {
67
if (event.action === 'reload') {

template/build/dev-server.js

Lines changed: 51 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,57 @@
1+
'use strict'
12
require('./check-versions')()
23

3-
var config = require('../config')
4+
const config = require('../config')
45
if (!process.env.NODE_ENV) {
56
process.env.NODE_ENV = JSON.parse(config.dev.env.NODE_ENV)
67
}
78

8-
var opn = require('opn')
9-
var path = require('path')
10-
var express = require('express')
11-
var webpack = require('webpack')
12-
var proxyMiddleware = require('http-proxy-middleware')
13-
var webpackConfig = {{#if_or unit e2e}}(process.env.NODE_ENV === 'testing' || process.env.NODE_ENV === 'production')
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 = {{#if_or unit e2e}}(process.env.NODE_ENV === 'testing' || process.env.NODE_ENV === 'production')
1415
? require('./webpack.prod.conf')
1516
: {{/if_or}}require('./webpack.dev.conf')
1617

1718
// default port where dev server listens for incoming traffic
18-
var port = process.env.PORT || config.dev.port
19+
const port = process.env.PORT || config.dev.port
1920
// automatically open browser, if not set will be false
20-
var autoOpenBrowser = !!config.dev.autoOpenBrowser
21+
const autoOpenBrowser = !!config.dev.autoOpenBrowser
2122
// Define HTTP proxies to your custom API backend
2223
// https://github.com/chimurai/http-proxy-middleware
23-
var proxyTable = config.dev.proxyTable
24+
const proxyTable = config.dev.proxyTable
2425

25-
var app = express()
26-
var compiler = webpack(webpackConfig)
26+
const app = express()
27+
const compiler = webpack(webpackConfig)
2728

28-
var devMiddleware = require('webpack-dev-middleware')(compiler, {
29+
const devMiddleware = require('webpack-dev-middleware')(compiler, {
2930
publicPath: webpackConfig.output.publicPath,
3031
quiet: true
3132
})
3233

33-
var hotMiddleware = require('webpack-hot-middleware')(compiler, {
34+
const hotMiddleware = require('webpack-hot-middleware')(compiler, {
3435
log: false,
3536
heartbeat: 2000
3637
})
3738
// force page reload when html-webpack-plugin template changes
38-
compiler.plugin('compilation', function (compilation) {
39-
compilation.plugin('html-webpack-plugin-after-emit', function (data, cb) {
40-
hotMiddleware.publish({ action: 'reload' })
41-
cb()
42-
})
43-
})
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)
4451

4552
// proxy api requests
4653
Object.keys(proxyTable).forEach(function (context) {
47-
var options = proxyTable[context]
54+
const options = proxyTable[context]
4855
if (typeof options === 'string') {
4956
options = { target: options }
5057
}
@@ -57,33 +64,41 @@ app.use(require('connect-history-api-fallback')())
5764
// serve webpack bundle output
5865
app.use(devMiddleware)
5966

60-
// enable hot-reload and state-preserving
61-
// compilation error display
62-
app.use(hotMiddleware)
63-
6467
// serve pure static assets
65-
var staticPath = path.posix.join(config.dev.assetsPublicPath, config.dev.assetsSubDirectory)
68+
const staticPath = path.posix.join(config.dev.assetsPublicPath, config.dev.assetsSubDirectory)
6669
app.use(staticPath, express.static('./static'))
6770

68-
var uri = 'http://localhost:' + port
71+
const uri = 'http://localhost:' + port
6972

7073
var _resolve
71-
var readyPromise = new Promise(resolve => {
74+
var _reject
75+
var readyPromise = new Promise((resolve, reject) => {
7276
_resolve = resolve
77+
_reject = reject
7378
})
7479

80+
var server
81+
var portfinder = require('portfinder')
82+
portfinder.basePort = port
83+
7584
console.log('> Starting dev server...')
7685
devMiddleware.waitUntilValid(() => {
77-
console.log('> Listening at ' + uri + '\n')
78-
// when env is testing, don't need open it
79-
if (autoOpenBrowser && process.env.NODE_ENV !== 'testing') {
80-
opn(uri)
81-
}
82-
_resolve()
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+
})
83100
})
84101

85-
var server = app.listen(port)
86-
87102
module.exports = {
88103
ready: readyPromise,
89104
close: () => {

template/build/utils.js

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
var path = require('path')
2-
var config = require('../config')
3-
var ExtractTextPlugin = require('extract-text-webpack-plugin')
1+
'use strict'
2+
const path = require('path')
3+
const config = require('../config')
4+
const ExtractTextPlugin = require('extract-text-webpack-plugin')
45

56
exports.assetsPath = function (_path) {
6-
var assetsSubDirectory = process.env.NODE_ENV === 'production'
7+
const assetsSubDirectory = process.env.NODE_ENV === 'production'
78
? config.build.assetsSubDirectory
89
: config.dev.assetsSubDirectory
910
return path.posix.join(assetsSubDirectory, _path)
@@ -12,7 +13,7 @@ exports.assetsPath = function (_path) {
1213
exports.cssLoaders = function (options) {
1314
options = options || {}
1415

15-
var cssLoader = {
16+
const cssLoader = {
1617
loader: 'css-loader',
1718
options: {
1819
minimize: process.env.NODE_ENV === 'production',
@@ -22,7 +23,7 @@ exports.cssLoaders = function (options) {
2223

2324
// generate loader string to be used with extract text plugin
2425
function generateLoaders (loader, loaderOptions) {
25-
var loaders = [cssLoader]
26+
const loaders = [cssLoader]
2627
if (loader) {
2728
loaders.push({
2829
loader: loader + '-loader',
@@ -58,10 +59,10 @@ exports.cssLoaders = function (options) {
5859

5960
// Generate loaders for standalone style files (outside of .vue)
6061
exports.styleLoaders = function (options) {
61-
var output = []
62-
var loaders = exports.cssLoaders(options)
63-
for (var extension in loaders) {
64-
var loader = loaders[extension]
62+
const output = []
63+
const loaders = exports.cssLoaders(options)
64+
for (const extension in loaders) {
65+
const loader = loaders[extension]
6566
output.push({
6667
test: new RegExp('\\.' + extension + '$'),
6768
use: loader

template/build/vue-loader.conf.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
var utils = require('./utils')
2-
var config = require('../config')
3-
var isProduction = process.env.NODE_ENV === 'production'
1+
'use strict'
2+
const utils = require('./utils')
3+
const config = require('../config')
4+
const isProduction = process.env.NODE_ENV === 'production'
45

56
module.exports = {
67
loaders: utils.cssLoaders({

template/build/webpack.base.conf.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
var path = require('path')
2-
var utils = require('./utils')
3-
var config = require('../config')
4-
var vueLoaderConfig = require('./vue-loader.conf')
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')
56

67
function resolve (dir) {
78
return path.join(__dirname, '..', dir)

template/build/webpack.dev.conf.js

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
var utils = require('./utils')
2-
var webpack = require('webpack')
3-
var config = require('../config')
4-
var merge = require('webpack-merge')
5-
var baseWebpackConfig = require('./webpack.base.conf')
6-
var HtmlWebpackPlugin = require('html-webpack-plugin')
7-
var FriendlyErrorsPlugin = require('friendly-errors-webpack-plugin')
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')
89

910
// add hot-reload related code to entry chunks
1011
Object.keys(baseWebpackConfig.entry).forEach(function (name) {

0 commit comments

Comments
 (0)