Skip to content

Commit 53bed7d

Browse files
committed
Merge remote-tracking branch 'vuejs-templates/master'
* vuejs-templates/master: (29 commits) Fix missing dependency bumps (vuejs-templates#987) Bumping Vue+VueRouter versions, some minor fixes. (vuejs-templates#986) stick to ES5 v1.1.1 downgrade airbnb config to ensure compaibility with eslint. Typo fixed: 'use stxrict' -> 'use strict' (vuejs-templates#955) We now have port-detection, so README should reflect that. Revision of wording in the README docs (vuejs-templates#958) add version tag to config/index.js add version tag to config/index.js Reference dev script in start script instead of copy pasting (vuejs-templates#894) Reference dev script in start script instead of copy pasting (vuejs-templates#894) Put hotMiddleware before proxyMiddleware in dev server (vuejs-templates#837) fix component filename Rename Hello component to HelloWorld (vuejs-templates#944) bump more deps Add .vscode to gitignore (vuejs-templates#845) update URL of ESLint to https (vuejs-templates#927) Fix small errors in webpack.prod.conf (vuejs-templates#897) Standardize base webpack module variable name (vuejs-templates#912) ... # Conflicts: # template/build/dev-server.js # template/build/webpack.prod.conf.js # template/package.json # template/src/components/HelloWorld.vue
2 parents 96c4446 + 6043118 commit 53bed7d

27 files changed

+191
-136
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.

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ $ npm install
2121
$ npm run dev
2222
```
2323

24-
If port 8080 is already in use on your machine you must change the port number in `/config/index.js`. Otherwise `npm run dev` will fail.
24+
The development server will run on port 8080 by default. If that port is already in use on your machine, the next free port will be used.
2525

2626
## What's Included
2727

@@ -36,7 +36,7 @@ If port 8080 is already in use on your machine you must change the port number i
3636
- JavaScript minified with [UglifyJS](https://github.com/mishoo/UglifyJS2).
3737
- HTML minified with [html-minifier](https://github.com/kangax/html-minifier).
3838
- CSS across all components extracted into a single file and minified with [cssnano](https://github.com/ben-eb/cssnano).
39-
- All static assets compiled with version hashes for efficient long-term caching, and a production `index.html` is auto-generated with proper URLs to these generated assets.
39+
- Static assets compiled with version hashes for efficient long-term caching, and an auto-generated production `index.html` with proper URLs to these generated assets.
4040
- Use `npm run build --report`to build with bundle size analytics.
4141

4242
- `npm run unit`: Unit tests run in PhantomJS with [Karma](http://karma-runner.github.io/0.13/index.html) + [Mocha](http://mochajs.org/) + [karma-webpack](https://github.com/webpack/karma-webpack).

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/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,4 @@ npm test
3333
{{/if_or}}
3434
```
3535

36-
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).
36+
For a detailed explanation on how things work, check out the [guide](http://vuejs-templates.github.io/webpack/) and [docs for vue-loader](http://vuejs.github.io/vue-loader).

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: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
/* eslint-disable */
2+
'use strict'
23
require('eventsource-polyfill')
34
var hotClient = require('webpack-hot-middleware/client?noInfo=true&reload=true')
45

template/build/dev-server.js

Lines changed: 45 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +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-
// force page reload when html-webpack-plugin template changes
39-
// temporory remove because webpack3 issue https://github.com/vuejs-templates/webpack/issues/751
39+
// currently disabled until this is resolved:
40+
// https://github.com/jantimon/html-webpack-plugin/issues/680
4041
// compiler.plugin('compilation', function (compilation) {
4142
// compilation.plugin('html-webpack-plugin-after-emit', function (data, cb) {
4243
// hotMiddleware.publish({ action: 'reload' })
4344
// cb()
4445
// })
4546
// })
4647

48+
// enable hot-reload and state-preserving
49+
// compilation error display
50+
app.use(hotMiddleware)
51+
4752
// proxy api requests
4853
Object.keys(proxyTable).forEach(function (context) {
49-
var options = proxyTable[context]
54+
let options = proxyTable[context]
5055
if (typeof options === 'string') {
5156
options = { target: options }
5257
}
@@ -59,33 +64,41 @@ app.use(require('connect-history-api-fallback')())
5964
// serve webpack bundle output
6065
app.use(devMiddleware)
6166

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

70-
var uri = 'http://localhost:' + port
71+
const uri = 'http://localhost:' + port
7172

7273
var _resolve
73-
var readyPromise = new Promise(resolve => {
74+
var _reject
75+
var readyPromise = new Promise((resolve, reject) => {
7476
_resolve = resolve
77+
_reject = reject
7578
})
7679

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

87-
var server = app.listen(port)
88-
89102
module.exports = {
90103
ready: readyPromise,
91104
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)