1
1
require ( './check-versions' ) ( )
2
2
3
- var config = require ( '../config' )
3
+ const config = require ( '../config' )
4
4
if ( ! process . env . NODE_ENV ) {
5
5
process . env . NODE_ENV = JSON . parse ( config . dev . env . NODE_ENV )
6
6
}
7
7
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 = ( process . env . NODE_ENV === 'testing' || process . env . NODE_ENV === 'production' )
8
+ const opn = require ( 'opn' )
9
+ const path = require ( 'path' )
10
+ const express = require ( 'express' )
11
+ const webpack = require ( 'webpack' )
12
+ const proxyMiddleware = require ( 'http-proxy-middleware' )
13
+ const webpackConfig = ( process . env . NODE_ENV === 'testing' || process . env . NODE_ENV === 'production' )
14
14
? require ( './webpack.prod.conf' )
15
15
: require ( './webpack.dev.conf' )
16
16
17
17
// default port where dev server listens for incoming traffic
18
- var port = process . env . PORT || config . dev . port
18
+ const port = process . env . PORT || config . dev . port
19
19
// automatically open browser, if not set will be false
20
- var autoOpenBrowser = ! ! config . dev . autoOpenBrowser
20
+ const autoOpenBrowser = ! ! config . dev . autoOpenBrowser
21
21
// Define HTTP proxies to your custom API backend
22
22
// https://github.com/chimurai/http-proxy-middleware
23
- var proxyTable = config . dev . proxyTable
23
+ const proxyTable = config . dev . proxyTable
24
24
25
- var app = express ( )
26
- var compiler = webpack ( webpackConfig )
25
+ const app = express ( )
26
+ const compiler = webpack ( webpackConfig )
27
27
28
- var devMiddleware = require ( 'webpack-dev-middleware' ) ( compiler , {
28
+ const devMiddleware = require ( 'webpack-dev-middleware' ) ( compiler , {
29
29
publicPath : webpackConfig . output . publicPath ,
30
30
quiet : true
31
31
} )
32
32
33
- var hotMiddleware = require ( 'webpack-hot-middleware' ) ( compiler , {
33
+ const hotMiddleware = require ( 'webpack-hot-middleware' ) ( compiler , {
34
34
log : false ,
35
35
heartbeat : 2000
36
36
} )
37
37
// 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
- } )
38
+ compiler . hooks . compilation . tap ( 'html-webpack-plugin-after-emit' , ( ) => {
39
+ hotMiddleware . publish ( {
40
+ action : 'reload'
41
+ } ) ;
42
+ } ) ;
44
43
45
44
// proxy api requests
46
45
Object . keys ( proxyTable ) . forEach ( function ( context ) {
47
- var options = proxyTable [ context ]
46
+ const options = proxyTable [ context ]
48
47
if ( typeof options === 'string' ) {
49
48
options = { target : options }
50
49
}
@@ -62,13 +61,13 @@ app.use(devMiddleware)
62
61
app . use ( hotMiddleware )
63
62
64
63
// serve pure static assets
65
- var staticPath = path . posix . join ( config . dev . assetsPublicPath , config . dev . assetsSubDirectory )
64
+ const staticPath = path . posix . join ( config . dev . assetsPublicPath , config . dev . assetsSubDirectory )
66
65
app . use ( staticPath , express . static ( './static' ) )
67
66
68
- var uri = 'http://localhost:' + port
67
+ const uri = 'http://localhost:' + port
69
68
70
- var _resolve
71
- var readyPromise = new Promise ( resolve => {
69
+ let _resolve
70
+ const readyPromise = new Promise ( resolve => {
72
71
_resolve = resolve
73
72
} )
74
73
@@ -82,7 +81,7 @@ devMiddleware.waitUntilValid(() => {
82
81
_resolve ( )
83
82
} )
84
83
85
- var server = app . listen ( port )
84
+ const server = app . listen ( port )
86
85
87
86
module . exports = {
88
87
ready : readyPromise ,
0 commit comments