Skip to content

Commit

Permalink
Merge remote-tracking branch 'vuejs-templates/master'
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
Ralph Pillichshammer committed Oct 30, 2017
2 parents 96c4446 + 6043118 commit 53bed7d
Show file tree
Hide file tree
Showing 27 changed files with 191 additions and 136 deletions.
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) 2013-present, Yuxi (Evan) You

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ $ npm install
$ npm run dev
```

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.
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.

## What's Included

Expand All @@ -36,7 +36,7 @@ If port 8080 is already in use on your machine you must change the port number i
- JavaScript minified with [UglifyJS](https://github.com/mishoo/UglifyJS2).
- HTML minified with [html-minifier](https://github.com/kangax/html-minifier).
- CSS across all components extracted into a single file and minified with [cssnano](https://github.com/ben-eb/cssnano).
- 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.
- 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.
- Use `npm run build --report`to build with bundle size analytics.

- `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).
Expand Down
3 changes: 2 additions & 1 deletion docs/backend.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ Let's take a look at the default `config/index.js`:

``` js
// config/index.js
var path = require('path')
'use strict'
const path = require('path')

module.exports = {
build: {
Expand Down
4 changes: 2 additions & 2 deletions docs/linter.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Linter Configuration

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.
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.

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

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

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).

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.
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.
2 changes: 1 addition & 1 deletion docs/prerender.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ npm install --save-dev prerender-spa-plugin

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

3. Configure it in the `plugins` array (also in **build/webpack.prod.conf.js**):
Expand Down
2 changes: 1 addition & 1 deletion template/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// http://eslint.org/docs/user-guide/configuring
// https://eslint.org/docs/user-guide/configuring

module.exports = {
root: true,
Expand Down
1 change: 1 addition & 0 deletions template/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ selenium-debug.log

# Editor directories and files
.idea
.vscode
*.suo
*.ntvs*
*.njsproj
Expand Down
2 changes: 1 addition & 1 deletion template/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,4 @@ npm test
{{/if_or}}
```

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).
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).
17 changes: 9 additions & 8 deletions template/build/build.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
'use strict'
require('./check-versions')()

process.env.NODE_ENV = 'production'

var ora = require('ora')
var rm = require('rimraf')
var path = require('path')
var chalk = require('chalk')
var webpack = require('webpack')
var config = require('../config')
var webpackConfig = require('./webpack.prod.conf')
const ora = require('ora')
const rm = require('rimraf')
const path = require('path')
const chalk = require('chalk')
const webpack = require('webpack')
const config = require('../config')
const webpackConfig = require('./webpack.prod.conf')

var spinner = ora('building for production...')
const spinner = ora('building for production...')
spinner.start()

rm(path.join(config.build.assetsRoot, config.build.assetsSubDirectory), err => {
Expand Down
21 changes: 11 additions & 10 deletions template/build/check-versions.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
var chalk = require('chalk')
var semver = require('semver')
var packageConfig = require('../package.json')
var shell = require('shelljs')
'use strict'
const chalk = require('chalk')
const semver = require('semver')
const packageConfig = require('../package.json')
const shell = require('shelljs')
function exec (cmd) {
return require('child_process').execSync(cmd).toString().trim()
}

var versionRequirements = [
const versionRequirements = [
{
name: 'node',
currentVersion: semver.clean(process.version),
Expand All @@ -23,9 +24,9 @@ if (shell.which('npm')) {
}

module.exports = function () {
var warnings = []
for (var i = 0; i < versionRequirements.length; i++) {
var mod = versionRequirements[i]
const warnings = []
for (let i = 0; i < versionRequirements.length; i++) {
const mod = versionRequirements[i]
if (!semver.satisfies(mod.currentVersion, mod.versionRequirement)) {
warnings.push(mod.name + ': ' +
chalk.red(mod.currentVersion) + ' should be ' +
Expand All @@ -38,8 +39,8 @@ module.exports = function () {
console.log('')
console.log(chalk.yellow('To use this template, you must update following to modules:'))
console.log()
for (var i = 0; i < warnings.length; i++) {
var warning = warnings[i]
for (let i = 0; i < warnings.length; i++) {
const warning = warnings[i]
console.log(' ' + warning)
}
console.log()
Expand Down
1 change: 1 addition & 0 deletions template/build/dev-client.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/* eslint-disable */
'use strict'
require('eventsource-polyfill')
var hotClient = require('webpack-hot-middleware/client?noInfo=true&reload=true')

Expand Down
77 changes: 45 additions & 32 deletions template/build/dev-server.js
Original file line number Diff line number Diff line change
@@ -1,52 +1,57 @@
'use strict'
require('./check-versions')()

var config = require('../config')
const config = require('../config')
if (!process.env.NODE_ENV) {
process.env.NODE_ENV = JSON.parse(config.dev.env.NODE_ENV)
}

var opn = require('opn')
var path = require('path')
var express = require('express')
var webpack = require('webpack')
var proxyMiddleware = require('http-proxy-middleware')
var webpackConfig = {{#if_or unit e2e}}(process.env.NODE_ENV === 'testing' || process.env.NODE_ENV === 'production')
const opn = require('opn')
const path = require('path')
const express = require('express')
const webpack = require('webpack')
const proxyMiddleware = require('http-proxy-middleware')
const webpackConfig = {{#if_or unit e2e}}(process.env.NODE_ENV === 'testing' || process.env.NODE_ENV === 'production')
? require('./webpack.prod.conf')
: {{/if_or}}require('./webpack.dev.conf')
// default port where dev server listens for incoming traffic
var port = process.env.PORT || config.dev.port
const port = process.env.PORT || config.dev.port
// automatically open browser, if not set will be false
var autoOpenBrowser = !!config.dev.autoOpenBrowser
const autoOpenBrowser = !!config.dev.autoOpenBrowser
// Define HTTP proxies to your custom API backend
// https://github.com/chimurai/http-proxy-middleware
var proxyTable = config.dev.proxyTable
const proxyTable = config.dev.proxyTable
var app = express()
var compiler = webpack(webpackConfig)
const app = express()
const compiler = webpack(webpackConfig)
var devMiddleware = require('webpack-dev-middleware')(compiler, {
const devMiddleware = require('webpack-dev-middleware')(compiler, {
publicPath: webpackConfig.output.publicPath,
quiet: true
})
var hotMiddleware = require('webpack-hot-middleware')(compiler, {
const hotMiddleware = require('webpack-hot-middleware')(compiler, {
log: false,
heartbeat: 2000
})
// force page reload when html-webpack-plugin template changes
// force page reload when html-webpack-plugin template changes
// temporory remove because webpack3 issue https://github.com/vuejs-templates/webpack/issues/751
// currently disabled until this is resolved:
// https://github.com/jantimon/html-webpack-plugin/issues/680
// compiler.plugin('compilation', function (compilation) {
// compilation.plugin('html-webpack-plugin-after-emit', function (data, cb) {
// hotMiddleware.publish({ action: 'reload' })
// cb()
// })
// })
// enable hot-reload and state-preserving
// compilation error display
app.use(hotMiddleware)
// proxy api requests
Object.keys(proxyTable).forEach(function (context) {
var options = proxyTable[context]
let options = proxyTable[context]
if (typeof options === 'string') {
options = { target: options }
}
Expand All @@ -59,33 +64,41 @@ app.use(require('connect-history-api-fallback')())
// serve webpack bundle output
app.use(devMiddleware)
// enable hot-reload and state-preserving
// compilation error display
app.use(hotMiddleware)
// serve pure static assets
var staticPath = path.posix.join(config.dev.assetsPublicPath, config.dev.assetsSubDirectory)
const staticPath = path.posix.join(config.dev.assetsPublicPath, config.dev.assetsSubDirectory)
app.use(staticPath, express.static('./static'))
var uri = 'http://localhost:' + port
const uri = 'http://localhost:' + port

var _resolve
var readyPromise = new Promise(resolve => {
var _reject
var readyPromise = new Promise((resolve, reject) => {
_resolve = resolve
_reject = reject
})

var server
var portfinder = require('portfinder')
portfinder.basePort = port

console.log('> Starting dev server...')
devMiddleware.waitUntilValid(() => {
console.log('> Listening at ' + uri + '\n')
// when env is testing, don't need open it
if (autoOpenBrowser && process.env.NODE_ENV !== 'testing') {
opn(uri)
}
_resolve()
portfinder.getPort((err, port) => {
if (err) {
_reject(err)
}
process.env.PORT = port
var uri = 'http://localhost:' + port
console.log('> Listening at ' + uri + '\n')
// when env is testing, don't need open it
if (autoOpenBrowser && process.env.NODE_ENV !== 'testing') {
opn(uri)
}
server = app.listen(port)
_resolve()
})
})

var server = app.listen(port)

module.exports = {
ready: readyPromise,
close: () => {
Expand Down
21 changes: 11 additions & 10 deletions template/build/utils.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
var path = require('path')
var config = require('../config')
var ExtractTextPlugin = require('extract-text-webpack-plugin')
'use strict'
const path = require('path')
const config = require('../config')
const ExtractTextPlugin = require('extract-text-webpack-plugin')

exports.assetsPath = function (_path) {
var assetsSubDirectory = process.env.NODE_ENV === 'production'
const assetsSubDirectory = process.env.NODE_ENV === 'production'
? config.build.assetsSubDirectory
: config.dev.assetsSubDirectory
return path.posix.join(assetsSubDirectory, _path)
Expand All @@ -12,7 +13,7 @@ exports.assetsPath = function (_path) {
exports.cssLoaders = function (options) {
options = options || {}

var cssLoader = {
const cssLoader = {
loader: 'css-loader',
options: {
minimize: process.env.NODE_ENV === 'production',
Expand All @@ -22,7 +23,7 @@ exports.cssLoaders = function (options) {

// generate loader string to be used with extract text plugin
function generateLoaders (loader, loaderOptions) {
var loaders = [cssLoader]
const loaders = [cssLoader]
if (loader) {
loaders.push({
loader: loader + '-loader',
Expand Down Expand Up @@ -58,10 +59,10 @@ exports.cssLoaders = function (options) {

// Generate loaders for standalone style files (outside of .vue)
exports.styleLoaders = function (options) {
var output = []
var loaders = exports.cssLoaders(options)
for (var extension in loaders) {
var loader = loaders[extension]
const output = []
const loaders = exports.cssLoaders(options)
for (const extension in loaders) {
const loader = loaders[extension]
output.push({
test: new RegExp('\\.' + extension + '$'),
use: loader
Expand Down
7 changes: 4 additions & 3 deletions template/build/vue-loader.conf.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
var utils = require('./utils')
var config = require('../config')
var isProduction = process.env.NODE_ENV === 'production'
'use strict'
const utils = require('./utils')
const config = require('../config')
const isProduction = process.env.NODE_ENV === 'production'

module.exports = {
loaders: utils.cssLoaders({
Expand Down
9 changes: 5 additions & 4 deletions template/build/webpack.base.conf.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
var path = require('path')
var utils = require('./utils')
var config = require('../config')
var vueLoaderConfig = require('./vue-loader.conf')
'use strict'
const path = require('path')
const utils = require('./utils')
const config = require('../config')
const vueLoaderConfig = require('./vue-loader.conf')

function resolve (dir) {
return path.join(__dirname, '..', dir)
Expand Down
15 changes: 8 additions & 7 deletions template/build/webpack.dev.conf.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
var utils = require('./utils')
var webpack = require('webpack')
var config = require('../config')
var merge = require('webpack-merge')
var baseWebpackConfig = require('./webpack.base.conf')
var HtmlWebpackPlugin = require('html-webpack-plugin')
var FriendlyErrorsPlugin = require('friendly-errors-webpack-plugin')
'use strict'
const utils = require('./utils')
const webpack = require('webpack')
const config = require('../config')
const merge = require('webpack-merge')
const baseWebpackConfig = require('./webpack.base.conf')
const HtmlWebpackPlugin = require('html-webpack-plugin')
const FriendlyErrorsPlugin = require('friendly-errors-webpack-plugin')

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

0 comments on commit 53bed7d

Please sign in to comment.