1- process . env . NODE_ENV = 'development'
1+ if ( ! process . env . NODE_ENV ) {
2+ process . env . NODE_ENV = 'development'
3+ }
4+
5+ require ( 'colors' )
26
37var
48 path = require ( 'path' ) ,
59 express = require ( 'express' ) ,
610 webpack = require ( 'webpack' ) ,
7- webpackConfig = require ( './webpack.config' ) ,
811 env = require ( './env-utils' ) ,
9- app = express ( ) ,
1012 opn = require ( 'opn' ) ,
13+ webpackConfig = require ( './webpack.config' ) ,
14+ app = express ( ) ,
1115 port = process . env . PORT || 8080 ,
12- compiler = webpack ( webpackConfig ) ,
13- devMiddleware = require ( 'webpack-dev-middleware' ) ( compiler , {
14- publicPath : webpackConfig . output . publicPath ,
15- stats : {
16- colors : true ,
17- chunks : false
18- }
19- } ) ,
20- hotMiddleware = require ( 'webpack-hot-middleware' ) ( compiler )
16+ uri = 'http://localhost:' + port
17+
18+ console . log ( ' Starting dev server with "' + ( process . argv [ 2 ] || 'mat' ) . bold + '" theme...' )
19+ console . log ( ' Will listen at ' + uri . bold )
20+ console . log ( ' Browser will open when build is ready.\n' )
2121
22+ var compiler = webpack ( webpackConfig )
23+
24+ var devMiddleware = require ( 'webpack-dev-middleware' ) ( compiler , {
25+ publicPath : webpackConfig . output . publicPath ,
26+ stats : {
27+ colors : true ,
28+ chunks : false
29+ }
30+ } )
31+
32+ var hotMiddleware = require ( 'webpack-hot-middleware' ) ( compiler )
2233// force page reload when html-webpack-plugin template changes
2334compiler . plugin ( 'compilation' , function ( compilation ) {
2435 compilation . plugin ( 'html-webpack-plugin-after-emit' , function ( data , cb ) {
@@ -39,7 +50,7 @@ app.use(hotMiddleware)
3950
4051// serve pure static assets
4152var staticsPath = path . posix . join ( webpackConfig . output . publicPath , 'statics/' )
42- app . use ( staticsPath , express . static ( './dev /statics' ) )
53+ app . use ( staticsPath , express . static ( './src /statics' ) )
4354
4455// try to serve Cordova statics for Play App
4556app . use ( express . static ( env . platform . cordovaAssets ) )
@@ -49,12 +60,6 @@ module.exports = app.listen(port, function (err) {
4960 console . log ( err )
5061 return
5162 }
52- var uri = 'http://localhost:' + port
53-
54- console . log ( 'Developing with "' + env . platform . theme + '" theme' )
55- console . log ( 'Listening at ' + uri + '\n' )
56- console . log ( 'Building. Please wait...' )
57- console . log ( 'Browser will open momentarily.\n' )
5863
5964 devMiddleware . waitUntilValid ( function ( ) {
6065 opn ( uri )
0 commit comments