File tree Expand file tree Collapse file tree 1 file changed +14
-12
lines changed Expand file tree Collapse file tree 1 file changed +14
-12
lines changed Original file line number Diff line number Diff line change @@ -5,27 +5,29 @@ const config = require('./webpack.config.development');
5
5
const logger = require ( 'express-logger' ) ;
6
6
7
7
const app = express ( ) ;
8
- const compiler = webpack ( config ) ;
9
8
10
- app . use ( require ( 'webpack-dev-middleware' ) ( compiler , {
11
- noInfo : true ,
12
- publicPath : config . output . publicPath ,
13
- stats : {
14
- colors : true
15
- }
16
- } ) ) ;
17
-
18
- app . use ( logger ( { path : `./log/${ process . env . NODE_ENV } .log` } ) ) ;
19
-
20
- // Run webpack middleware only in dev environment
21
9
if ( process . env . NODE_ENV !== 'production' ) {
10
+ // Run webpack middleware only in dev environment
11
+ const compiler = webpack ( config ) ;
12
+ app . use ( require ( 'webpack-dev-middleware' ) ( compiler , {
13
+ noInfo : true ,
14
+ publicPath : config . output . publicPath ,
15
+ stats : {
16
+ colors : true
17
+ }
18
+ } ) ) ;
22
19
app . use ( require ( 'webpack-hot-middleware' ) ( compiler ) ) ;
20
+ } else {
21
+ // Use build folder for serving static assets in prod environment
22
+ app . use ( express . static ( 'build' ) ) ;
23
23
}
24
24
25
25
app . get ( '*' , function ( req , res ) {
26
26
res . sendFile ( path . join ( __dirname , './public/index.html' ) ) ;
27
27
} ) ;
28
28
29
+ app . use ( logger ( { path : `./log/${ process . env . NODE_ENV } .log` } ) ) ;
30
+
29
31
app . listen ( 8001 , '0.0.0.0' , function ( err ) {
30
32
if ( err ) {
31
33
console . log ( err ) ;
You can’t perform that action at this time.
0 commit comments