@@ -19,27 +19,29 @@ const app = express();
19
19
const PORT = process . env . PORT || 3015 ;
20
20
const DIST_FOLDER = join ( process . cwd ( ) , 'dist' ) ;
21
21
22
- // Our index.html we'll use as our template
23
- const template = readFileSync ( join ( DIST_FOLDER , 'browser' , 'index.html' ) ) . toString ( ) ;
24
-
25
- // * NOTE :: leave this as require() since this file is built Dynamically from webpack
26
- const { AppServerModuleNgFactory, LAZY_MODULE_MAP } = require ( './dist/server/main.js' ) ;
27
-
28
- const { provideModuleMap } = require ( '@nguniversal/module-map-ngfactory-loader' ) ;
29
-
30
- app . engine ( 'html' , ( _ , options , callback ) => {
31
- renderModuleFactory ( AppServerModuleNgFactory , {
32
- // Our index.html
33
- document : template ,
34
- url : options . req . url ,
35
- // DI so that we can get lazy-loading to work differently (since we need it to just instantly render it)
36
- extraProviders : [
37
- provideModuleMap ( LAZY_MODULE_MAP )
38
- ]
39
- } ) . then ( html => {
40
- callback ( null , html ) ;
22
+ if ( process . env . NODE_ENV !== 'dev' ) {
23
+ // Our index.html we'll use as our template
24
+ const template = readFileSync ( join ( DIST_FOLDER , 'browser' , 'index.html' ) ) . toString ( ) ;
25
+
26
+ // * NOTE :: leave this as require() since this file is built Dynamically from webpack
27
+ const { AppServerModuleNgFactory, LAZY_MODULE_MAP } = require ( './dist/server/main.js' ) ;
28
+
29
+ const { provideModuleMap } = require ( '@nguniversal/module-map-ngfactory-loader' ) ;
30
+
31
+ app . engine ( 'html' , ( _ , options , callback ) => {
32
+ renderModuleFactory ( AppServerModuleNgFactory , {
33
+ // Our index.html
34
+ document : template ,
35
+ url : options . req . url ,
36
+ // DI so that we can get lazy-loading to work differently (since we need it to just instantly render it)
37
+ extraProviders : [
38
+ provideModuleMap ( LAZY_MODULE_MAP )
39
+ ]
40
+ } ) . then ( html => {
41
+ callback ( null , html ) ;
42
+ } ) ;
41
43
} ) ;
42
- } ) ;
44
+ }
43
45
44
46
app . use ( '/api' , api ) ;
45
47
app . set ( 'view engine' , 'html' ) ;
0 commit comments