11'use strict'
22const fs = require ( 'fs' )
33const path = require ( 'path' )
4+ const chalk = require ( 'chalk' )
45const express = require ( 'express' )
56const webpack = require ( 'webpack' )
6- const fse = require ( 'fs-extra' )
77const webpackConfig = require ( './webpack.dev' )
88const config = require ( './config' )
99
1010const app = express ( )
1111
1212const port = config . port
1313webpackConfig . entry . client = [
14- `webpack-hot-middleware/client{{#electron}}? path=http://localhost:${ port } /__webpack_hmr{{/electron}}` ,
14+ `webpack-hot-middleware/client?reload=true {{#electron}}& path=http://localhost:${ port } /__webpack_hmr{{/electron}}` ,
1515 webpackConfig . entry . client
1616]
1717{ { #electron} }
1818
1919webpackConfig . output . publicPath = `http://localhost:${ port } /assets/`
2020{ { / e l e c t r o n } }
2121
22- const compiler = webpack ( webpackConfig )
22+ let compiler
23+
24+ try {
25+ compiler = webpack ( webpackConfig )
26+ } catch ( err ) {
27+ console . log ( err . message )
28+ process . exit ( 1 )
29+ }
2330
2431const devMiddleWare = require ( 'webpack-dev-middleware' ) ( compiler , {
2532 publicPath : webpackConfig . output . publicPath ,
@@ -28,7 +35,9 @@ const devMiddleWare = require('webpack-dev-middleware')(compiler, {
2835 modules : false ,
2936 children : false ,
3037 chunks : false ,
31- chunkModules : false
38+ chunkModules : false ,
39+ hash : false ,
40+ timings : false
3241 }
3342} )
3443app . use ( devMiddleWare )
@@ -37,13 +46,10 @@ app.use(require('webpack-hot-middleware')(compiler))
3746const mfs = devMiddleWare . fileSystem
3847const file = path . join ( webpackConfig . output . path , 'index.html' )
3948
40- devMiddleWare . waitUntilValid ( ( ) => {
41- const html = mfs . readFileSync ( file )
42- fse . ensureDirSync ( path . dirname ( file ) )
43- fs . writeFile ( file , html , 'utf8' , err => {
44- if ( err ) console . log ( err )
45- } )
46- } )
49+ console . log ( `\n > VuePack is running at ${ chalk . yellow ( `http://localhost:${ port } ` ) } \n` )
50+
51+
52+ devMiddleWare . waitUntilValid ( )
4753
4854app . get ( '*' , ( req , res ) => {
4955 devMiddleWare . waitUntilValid ( ( ) => {
0 commit comments